Class ConcreteTypeMigration
Migration from base type to multiple concrete types based on object's field values. If you need to migrate only by single field you can use simplified ConcreteTypeMigration<TDiscriminator>.
Inheritance
Inherited Members
Namespace: Eco.Core.Serialization.Migrations
Assembly: Eco.Core.dll
Syntax
public class ConcreteTypeMigration : InstanceMigration, IInstanceMigration, IReferenceMigration, IClassMigration, IMigration
Constructors
ConcreteTypeMigration(String, IEnumerable<String>, Func<ReaderDataInput[], String>)
Initializes a new instance of the ConcreteTypeMigration class.
It will convert every class of baseTypeName
into more specific (concrete) type using fieldNames
(members of the object).
For every migrated object it will invoke typeMapper
with array of ReaderDataInput for fieldNames
in same order and the function should return new type name.
Declaration
public ConcreteTypeMigration(string baseTypeName, IEnumerable<string> fieldNames, Func<ReaderDataInput[], string> typeMapper)
Parameters
Type | Name | Description |
---|---|---|
System.String | baseTypeName | |
System.Collections.Generic.IEnumerable<System.String> | fieldNames | |
System.Func<ReaderDataInput[], System.String> | typeMapper |
ConcreteTypeMigration(String, IEnumerable<String>, Func<Object[], String>)
Initializes a new instance of the ConcreteTypeMigration class.
It will convert every class of baseTypeName
into more specific (concrete) type using field values of fieldNames
.
For every migrated object it will invoke typeMapper
with array of values for fieldNames
in same order and the function should return new type name.
Declaration
public ConcreteTypeMigration(string baseTypeName, IEnumerable<string> fieldNames, Func<object[], string> typeMapper)
Parameters
Type | Name | Description |
---|---|---|
System.String | baseTypeName | |
System.Collections.Generic.IEnumerable<System.String> | fieldNames | |
System.Func<System.Object[], System.String> | typeMapper |
Methods
MigrateInstance(MigrationContext)
Migrates an instance with provided context
.
It may modify context
with one of following migration results:
- ReferenceTypeName != null means that binary content was fully consumed and a reference should be serialized instead. It should contains the referenced object id in ReferenceId;
- Schema modified and output schema is a class schema, it means that original class binary data was replaced with another class binary data and it should use new object serializer;
- Schema modified and output schema is the cached serializer schema, it means that original binary content was consumed and object instance created and cached for upcoming deserialization call;
- Schema modified, but output schema not class or cached object, it means that Reader contains compatible binary data. If reader wasn't modified then it will be reset to initial position.
- Schema not modified, if Reader modified then it should be re-serialized with original serializer or just reset reader position otherwise.
Declaration
public override void MigrateInstance(MigrationContext context)
Parameters
Type | Name | Description |
---|---|---|
MigrationContext | context |