Allow to serialize CanClose if set to true for LayoutAnchorable instance #187
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.
Hi Dirk, this one is a bit more risky so leaving up to you to decide whether to accept.
The problem here is that with the original code in LayoutContent CanClose could be serialized only if its value is false. Now in LayoutAnchorable the default of CanClose is altered to false but if for some reason you would like to change CanClose to true for LayoutAnchorable (i.e. to make some tools closable by behaviour) it won't be possible to serialize that change because serialization code in LayoutContent class would serialize only if value is false.
I added another field _canCloseDefault in LayoutContent and in serialization code CanClose is checked against that value to decide whether to save it. In LayoutAnchorable _canClose value is set to false by default but so is _canCloseDefault and the serializer will now save if the value is true.
It should be all good but there is a side effect of that change. Now for LayoutAnchorables CanClose will no longer be saved in XML by default because it is false and value equals to its default. That's in contrast with previous implementation which always saved CanClose for LayoutAnchorables because it was false.