uSync icon indicating copy to clipboard operation
uSync copied to clipboard

Possibility to extend SyncHandlerRoot protected methods

Open bielu opened this issue 1 year ago • 3 comments

Is your feature request related to a problem? Please describe. Hi Kevin, I wanted modify dictionary handler, to populate all languages with no value with my default language value, but noticed this DeserializeItem method is not virtual which make it not possible for me to override logic around this item, without messing with whole ImportElement method or ISyncSerializer for dictionaries. Describe the solution you'd like I would like add virtual flag to method DeserializeItem

Describe alternatives you've considered Replacing DictionaryItemSerializer but even have more troubles as DeserializeTranslations is private and not virtual.

Additional context My requirement is to be able to parse item and add translation in existing languages without need of them existing in usync file.

bielu avatar Oct 30 '24 10:10 bielu

Also I am happy to submit pr if you are okay with it Kevin :)

bielu avatar Oct 30 '24 10:10 bielu

I think you might be on safer gound overriding the DictionaryItemSerializer and then replace its 'DeserializeCore` method

DeserlizeItem, essentially calls the serializer.Deserializer method (in SyncSerializerRoot) - and that is a wrapper that does the checks for changes in files and rules before calling the defined serializer's DeserializeCore method.

By overriding this method, you keep all of the goodness of the rules, the checks (and the performance stuff baked in). and then you can do what you need in a custom serializer?

if you need to make the private methods inside the DictionaryItem serializer public then thats a bit less of a change for us to keep track of (just worried we make that public and i am more likey to break the logic of it down the line).

KevinJump avatar Oct 30 '24 10:10 KevinJump

@KevinJump I think I can do with DeserializeTranslations protected virtual :) but will check it when doing pr ;)

bielu avatar Oct 30 '24 10:10 bielu

Fixed in v13.2.6

KevinJump avatar Jan 09 '25 11:01 KevinJump