-
-
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 RuntimeTypeModel.Add(type, true)
does.
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.
By default subtypes are automatically registered to their base types as with SerializeDerivedType
attribute (if they were not registered before). They have automatic fields numbers assigned starting from AutoRegisteringSubtypesFirstTag
. You may set DisableAutoRegisteringSubtypes
to disable this behavior.
You can enable System.Serializable
attribute support by modifying AcceptableAttributes
property. For this attribute ImplicitFields.AllFields
mode is used.
Please read xmldocs on AutoAddStrategy
using your IDE IntelliSense.
One of important settings is AutoAddStrategy.ImplicitFallbackMode
which allows you to setup ImplicitFields
behavior for not recognized types.
To alter attributes mapping or add a support for new attributes you can set properties TypeMapper
and MemberMapper
on AutoAddStrategy
.
Both mappers are also extendable, you can pass your custom handlers to their default implementation constructors. To get default handlers list use CreateDefault(Type|Member)MapperHandlers
on AutoAddStrategy
. 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.
In previous versions the default implementation of IAutoAddStrategy
had DefaultAutoAddStrategy
class name.