-
Notifications
You must be signed in to change notification settings - Fork 3
Changing auto add behavior
When AqlaSerializer meets unknown type it tries to recognize it automatically the same way as RuntimeTypeMode.Add(type, true)
does.
By default subtypes are automatically registered to their base types as with ProtoInclude
attribute (if they were not registered before). All member types are automatically registered too.
You can get or set the current IAutoAddStrategy
with RuntimeTypeModel.AutoAddStrategy
. The default strategy can be casted to AutoAddStrategy
so you can alter its settings. To avoid unpredictable side effects please don't try hot-swapping AutoAddStrategy
or changing its settings between adding related (via inheritance or composition) types.
One of important settings is AutoAddStrategy.ImplicitFallbackMode
property which allows you to setup ImplicitFields
behavior for not recognized types.
The auto-adding behavior can be extended. To alter attributes mapping or add a support for new attributes you can set properties AutoAddStrategy.TypeMapper
and AutoAddStrategy.MemberMapper
. Both mappers are also extendable, you can pass your custom handlers to their default implementation constructors. To get default handlers list use CreateDefaultTypeMapperHandlers
and CreateDefaultMemberMapperHandlers
on AutoAddStrategy
respectively. Please see the source code to understand how to implement your custom handlers.
Also you may implement your own custom IAutoAddStrategy
; note that it's required to inherit AutoAddStrategy
so you have an access to required protected methods.
You can enable System.Serializable
attribute support by modifying AutoAddStrategy.AcceptableAttributes
property. For this attribute ImplicitFields.AllFields
mode is used.