Skip to content

Batch types registration

Vladyslav Taranov edited this page Nov 3, 2015 · 11 revisions

Use RuntimeTypeModel.Add(Assembly) or Add(Type[]) to add all types with all dependencies included.

This can be especially usable when you prepare your model for compilation.

Because subtypes have automatically generated field numbers it's required to export/import them if you want your RuntimeTypeModels to "understand" each other: Serialize(ExportTypeRelations()) - ImportTypeRelations(Deserialize()) . All the subtypes are imported in the correct order so they have the same field numbers as in their original model. Remember that the import/export functionality does not synchronize fields but only subtypes. The point of this is the fact that property numbers don't depend on the type adding order but subtype numbers do.

As an alternative you can just add types in the same order for both RuntimeTypeModels or specify derived types field numbers with SerializeDerivedType attribute.

Precompilation bakes subtype numbers into dll so import/export is only needed for RuntimeTypeModel.