Class MigrationManager
Class responsible for migration stuff. It holds migrations, migration types for different versions and can apply them.
Inheritance
System.Object
MigrationManager
Assembly: Eco.Core.dll
Syntax
public class MigrationManager : Object
Constructors
MigrationManager()
Declaration
public MigrationManager()
Fields
MigrationInfo
Declaration
public InfoBuilder MigrationInfo
Field Value
MigrationLog
Declaration
public InfoBuilder MigrationLog
Field Value
Properties
CachedObjectsSerializer
Declaration
public CachedObjectSerializer CachedObjectsSerializer { get; }
Property Value
HasMigrations
Declaration
public bool HasMigrations { get; }
Property Value
Type |
Description |
System.Boolean |
|
NewVersion
Declaration
public SimpleSerializer NewVersion { get; }
Property Value
ObjectSerializer
Declaration
public ObjectSerializer ObjectSerializer { get; }
Property Value
OldVersion
Declaration
public SimpleSerializer OldVersion { get; }
Property Value
Methods
AddDataStoreMigration(Type, IDataStoreMigration)
Declaration
public void AddDataStoreMigration(Type type, IDataStoreMigration dataStoreMigration)
Parameters
AddMigratedType(Double, MigratedTypeAttribute)
Adds MigratedTypeAttribute which will be used to access erased information for migrated type (i.e. if it was struct and was changed to class or vice versa).
Declaration
public void AddMigratedType(double sinceVersion, MigratedTypeAttribute migratedType)
Parameters
AddMigration(Double, IClassMigration)
Declaration
public void AddMigration(double sinceVersion, IClassMigration classMigration)
Parameters
Type |
Name |
Description |
System.Double |
sinceVersion |
|
IClassMigration |
classMigration |
|
AddMigrations(Double, IEnumerable<IClassMigration>)
Adds all migrations from enumerable with same sinceVersion
.
Declaration
public void AddMigrations(double sinceVersion, IEnumerable<IClassMigration> migrations)
Parameters
Type |
Name |
Description |
System.Double |
sinceVersion |
|
System.Collections.Generic.IEnumerable<IClassMigration> |
migrations |
|
AddReferencedObjectSerializer(String, Type, Func<Object, Object>)
Declaration
public ReferencedObjectSerializer AddReferencedObjectSerializer(string keySchemaType, Type type, Func<object, object> referenceResolver)
Parameters
Type |
Name |
Description |
System.String |
keySchemaType |
|
System.Type |
type |
|
System.Func<System.Object, System.Object> |
referenceResolver |
|
Returns
AddReferencedObjectSerializer<TKey, TReference>(Func<TKey, TReference>)
Declaration
public ReferencedObjectSerializer AddReferencedObjectSerializer<TKey, TReference>(Func<TKey, TReference> referenceResolver)
Parameters
Type |
Name |
Description |
System.Func<TKey, TReference> |
referenceResolver |
|
Returns
Type Parameters
Name |
Description |
TKey |
|
TReference |
|
AddSchemaMember(ImmutableSerializerSchema, String, String)
Declaration
public ImmutableSerializerSchema AddSchemaMember(ImmutableSerializerSchema schema, string memberName, string memberType)
Parameters
Returns
ChangeSchemaMember(ImmutableSerializerSchema, String, String, String)
Declaration
public ImmutableSerializerSchema ChangeSchemaMember(ImmutableSerializerSchema schema, string oldMemberName, string newMemberName, string newMemberType)
Parameters
Type |
Name |
Description |
ImmutableSerializerSchema |
schema |
|
System.String |
oldMemberName |
|
System.String |
newMemberName |
|
System.String |
newMemberType |
|
Returns
ChangeSchemaType(ImmutableSerializerSchema, String)
Declaration
public ImmutableSerializerSchema ChangeSchemaType(ImmutableSerializerSchema schema, string schemaType)
Parameters
Returns
CopySchemaContent(ImmutableSerializerSchema, BinaryReader, BinaryWriter)
Copies schema content from reader to writer without actually deserializing it.
Declaration
public void CopySchemaContent(ImmutableSerializerSchema schema, BinaryReader reader, BinaryWriter writer)
Parameters
Type |
Name |
Description |
ImmutableSerializerSchema |
schema |
schema.
|
System.IO.BinaryReader |
reader |
reader to read from.
|
System.IO.BinaryWriter |
writer |
writer to write content to.
|
CreateMemberlessSchema(String)
Declaration
public ImmutableSerializerSchema CreateMemberlessSchema(string schemaType)
Parameters
Type |
Name |
Description |
System.String |
schemaType |
|
Returns
CreateSchema(SerializerSchema)
Declaration
public ImmutableSerializerSchema CreateSchema(SerializerSchema schema)
Parameters
Returns
CreateSchema(String)
Declaration
public ImmutableSerializerSchema CreateSchema(string schemaType)
Parameters
Type |
Name |
Description |
System.String |
schemaType |
|
Returns
CreateSchema(String, ObjectSerializer)
Declaration
public ImmutableSerializerSchema CreateSchema(string schemaType, ObjectSerializer membersSerializer)
Parameters
Type |
Name |
Description |
System.String |
schemaType |
|
ObjectSerializer |
membersSerializer |
|
Returns
DecodeObject(ImmutableSerializerSchema, BinaryReader)
Decodes object using provided schema.
Declaration
public DecodedObject DecodeObject(ImmutableSerializerSchema schema, BinaryReader reader)
Parameters
Returns
DecodeObject(MigrationContext)
Migrates context
and returns DecodedObject (either reference or instance).
Declaration
public DecodedObject DecodeObject(MigrationContext context)
Parameters
Returns
EncodeWith(ISerializer, BinaryWriter, Object, SerializeFlags)
Declaration
public void EncodeWith(ISerializer serializer, BinaryWriter writer, object value, SerializeFlags flags)
Parameters
GetOrCreateObjectSerializer(ImmutableSerializerSchema)
Declaration
public ObjectSerializer GetOrCreateObjectSerializer(ImmutableSerializerSchema schema)
Parameters
Returns
GetOrCreateSerializer(ImmutableSerializerSchema)
Declaration
public ISerializer GetOrCreateSerializer(ImmutableSerializerSchema schema)
Parameters
Returns
GetOrCreateSerializerFromSchemaType(String)
Tries to find serializer for schemaType
. If not exists then either will try to create new serializer for container types (dictionary or collection) or returns default ObjectSerializer for class schema types.
Declaration
public ISerializer GetOrCreateSerializerFromSchemaType(string schemaType)
Parameters
Type |
Name |
Description |
System.String |
schemaType |
|
Returns
GetOrCreateVersionedSerializer(ImmutableSerializerSchema, Double)
Gets or creates versioned serializer. If migration for schema
required then it will start from version
instead of current schema version.
Typical use-case if you have a DataMigration which performs migration on a member which has migrations before and after that data migration.
Then you fist migrate the member up-to version compatible with data migration then perform modifications for member from data modification itself and serialize it back with data migration version.
When member will be decoded it will apply all migrations after the version of data migration.
Declaration
public ObjectSerializer GetOrCreateVersionedSerializer(ImmutableSerializerSchema schema, double version)
Parameters
Returns
GetSerializerFromId(Int32)
Declaration
public ISerializer GetSerializerFromId(int id)
Parameters
Type |
Name |
Description |
System.Int32 |
id |
|
Returns
GetSerializerFromSchemaType(String)
Tries to find serializer for schemaType
. If not exists then returns default ObjectSerializer for class schema types or throws exception.
Declaration
public ISerializer GetSerializerFromSchemaType(string schemaType)
Parameters
Type |
Name |
Description |
System.String |
schemaType |
|
Returns
GetTypeBySchemaType(String)
Declaration
public Type GetTypeBySchemaType(string schemaType)
Parameters
Type |
Name |
Description |
System.String |
schemaType |
|
Returns
Type |
Description |
System.Type |
|
Init(SimpleSerializer, SimpleSerializer, Double)
Declaration
public void Init(SimpleSerializer oldVersion, SimpleSerializer newVersion, double schemaVersion)
Parameters
IsMigrationOnlyType(Type)
Checks if type
is a type which only used during migration. Such a type should be fully serialized instead of CachedObjectsSerializer usage.
Declaration
public bool IsMigrationOnlyType(Type type)
Parameters
Type |
Name |
Description |
System.Type |
type |
|
Returns
Type |
Description |
System.Boolean |
|
IsNullableType(String, Double)
Returns if type is nullable in specific schema version.
Declaration
public bool IsNullableType(string schemaType, double version)
Parameters
Type |
Name |
Description |
System.String |
schemaType |
schema type.
|
System.Double |
version |
schema version.
|
Returns
Type |
Description |
System.Boolean |
true - if schema type nullable in specified schema version.
|
LogMigrationInfo()
Declaration
public void LogMigrationInfo()
MigrateDataStore(DataStore.ExclusiveAccess, Type, Action<Object, String>)
Declaration
public void MigrateDataStore(DataStore.ExclusiveAccess dataStoreAccess, Type type, Action<object, string> createFunc)
Parameters
Type |
Name |
Description |
DataStore.ExclusiveAccess |
dataStoreAccess |
|
System.Type |
type |
|
System.Action<System.Object, System.String> |
createFunc |
|
Reads schema, returns decoded data for every requested member and returns member ranges mapping to positions in the stream.
Reader positioned at the end of schema data after call to the method.
Declaration
public Dictionary<IDataInput, ReaderDataInput> ReadMembers(BinaryReader reader, IDictionary<string, MemberDataInput> members, ImmutableSerializerSchema schema, out Dictionary<string, (long, long)> memberRanges)
Parameters
Type |
Name |
Description |
System.IO.BinaryReader |
reader |
|
System.Collections.Generic.IDictionary<System.String, MemberDataInput> |
members |
|
ImmutableSerializerSchema |
schema |
|
System.Collections.Generic.Dictionary<System.String, System.ValueTuple<System.Int64, System.Int64>> |
memberRanges |
|
Returns
Reads schema, returns decoded data for every requested member and returns member ranges mapping to positions in the stream.
Reader positioned at the end of schema data after call to the method.
Declaration
public Dictionary<IDataInput, ReaderDataInput> ReadMembers(BinaryReader reader, Stream instanceStream, IDictionary<string, MemberDataInput> members, ImmutableSerializerSchema schema, out Dictionary<string, (long, long)> memberRanges)
Parameters
Type |
Name |
Description |
System.IO.BinaryReader |
reader |
binary reader to read data from.
|
System.IO.Stream |
instanceStream |
stream with instance data which will advance with reader . It may be reader's base stream or tapped stream from ReadOnlyForkStream.
|
System.Collections.Generic.IDictionary<System.String, MemberDataInput> |
members |
set of requested member names.
|
ImmutableSerializerSchema |
schema |
schema describing data to read.
|
System.Collections.Generic.Dictionary<System.String, System.ValueTuple<System.Int64, System.Int64>> |
memberRanges |
output dictionary with mapping between member names and they reader's positions.
|
Returns
Reads schema, saves to data
decoded data for every requested member and returns member ranges mapping to positions in the stream.
Reader positioned at the end of schema data after call to the method.
Declaration
public void ReadMembersTo(BinaryReader reader, Stream instanceStream, IDictionary<string, MemberDataInput> members, ImmutableSerializerSchema schema, Dictionary<IDataInput, ReaderDataInput> data, out Dictionary<string, (long, long)> memberRanges)
Parameters
Type |
Name |
Description |
System.IO.BinaryReader |
reader |
binary reader to read data from.
|
System.IO.Stream |
instanceStream |
stream with instance data which will advance with reader . It may be reader's base stream or tapped stream from ReadOnlyForkStream.
|
System.Collections.Generic.IDictionary<System.String, MemberDataInput> |
members |
set of requested member names.
|
ImmutableSerializerSchema |
schema |
schema describing data to read.
|
System.Collections.Generic.Dictionary<IDataInput, ReaderDataInput> |
data |
data dictionary to store requested members data.
|
System.Collections.Generic.Dictionary<System.String, System.ValueTuple<System.Int64, System.Int64>> |
memberRanges |
output dictionary with mapping between member names and they reader's positions.
|
RemoveSchemaMember(ImmutableSerializerSchema, String)
Declaration
public ImmutableSerializerSchema RemoveSchemaMember(ImmutableSerializerSchema schema, string memberName)
Parameters
Returns
SetMigrationTypes(IEnumerable<MigrationType>)
Declaration
public void SetMigrationTypes(IEnumerable<MigrationType> migrationTypes)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<MigrationType> |
migrationTypes |
|
SkipSchemaContent(ImmutableSerializerSchema, BinaryReader)
Skips schema content from reader without actually deserializing it.
Declaration
public void SkipSchemaContent(ImmutableSerializerSchema schema, BinaryReader reader)
Parameters
Extension Methods