Class MigrationTypeAttribute
Attribute for marking class as MigrationType (read more about migration types in the MigrationType documentation). Can be used in two ways:
- As SerializedAttribute type attribute, then the attributed type will be used to represent new type if MigrationType not specified. The representing type shouldn't exactly match target type, but only have necessary fields. This type may not even existing in final schema, but used as intermediate type (i.e. if you have Schema v1 with type Foo and need to migrate to Schema v3 with type Baz, but in Schema v2 type Foo was renamed to Bar and then to Baz in v3. In this case you may need to migrate first to MigrationType("Bar", SinceVersion=2) and then you will be able to migrate from Bar to Baz for version v3).
- As migration class attribute (the type with MigrationAttribute). In most cases when used with migration TargetSchemaType is same as MigrationType as well as SinceVersion. In that cases you can just use constructor with type parameter which sets MigrationType to same value as TargetSchemaType and SinceVersion will be used from MigrationAttribute. It will help to avoid copy paste and potential errors when these values changes not synced.
Inheritance
Namespace: Eco.Core.Serialization.Migrations.Attributes
Assembly: Eco.Core.dll
Syntax
public class MigrationTypeAttribute : Attribute
Constructors
MigrationTypeAttribute(String)
Sets TargetSchemaType from classNameOrSchemaType
. MigrationType should be specified explicitly or will use attributed type.
Declaration
public MigrationTypeAttribute(string classNameOrSchemaType)
Parameters
Type | Name | Description |
---|---|---|
System.String | classNameOrSchemaType |
MigrationTypeAttribute(Type)
Sets both TargetSchemaType and MigrationType from targetType
.
Declaration
public MigrationTypeAttribute(Type targetType)
Parameters
Type | Name | Description |
---|---|---|
System.Type | targetType |
Properties
MigrationType
The type representing MigrationType. May be same as TargetSchemaType or it's simplified version. Also may represent intermediate type which existed between one of previous supported schema versions and latest schema version.
Declaration
public Type MigrationType { get; set; }
Property Value
Type | Description |
---|---|
System.Type |
SinceVersion
The first version when this type was added. Can't be used with migrations before that version. If not specified then will be populated from MigrationAttribute on same type.
Declaration
public double SinceVersion { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
TargetSchemaType
Schema type for the migration type. May be different from MigrationType (i.e. class[Foo] as schema type and FooV1 as migration type).
Declaration
public string TargetSchemaType { get; }
Property Value
Type | Description |
---|---|
System.String |