Added support for decoupled, type-dependent node-encoding strategies #26
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The current way that
AttributeEncodingStrategy
is implemented does not allow for compositional strategy delegation.After a bit of a redesign
XMLParsing
now supports this (while remaining the option to keep doing it the current way):Note that the
XMLNodeEncodingStrategy
protocol here is user-specified and you're free to do things your own way (i.e. nobody forces one to add the node encoding strategy to the encodable value type itself, you're free to put it in a dedicated encoding strategy, which could then also be shared across values).I personally prefer to have small neatly scoped encoding strategies that can easily be composed. But if one wishes to use a plain closure as strategy, there's nothing holding one up from doing so:
Either way using the above API like this …
… produces an output like this: