Show / Hide Table of Contents

Class DataInput

DataInput defines input for migration which optionally may have own member inputs. During migration it may Eco.Core.Serialization.Migrations.DataMigrations.DataInput.Read(Eco.Core.Serialization.Migrations.MigrationManager,System.IO.BinaryReader,System.IO.Stream,Eco.Core.Serialization.Serializers.ISerializer,System.Collections.Generic.Dictionary{Eco.Core.Serialization.Migrations.DataMigrations.IDataInput,Eco.Core.Serialization.Migrations.DataMigrations.ReaderDataInput}) from System.IO.BinaryReader ReaderDataInput for itself and for all own members and update data mapping. Using data inputs let you avoid full objects deserialization (and so delay it until actual deserialization stage keeping it binary compatible with migrations for newer versions). I.e. you need to add a comment containing creator id to some entity. With data input it can be done like:

this.AddDataMigration(typeof(SomeType), dm => {
    var creatorId = dm.Member("Creator").ReferenceId();
    dm.AddMember<string>("Comment", new[] { creatorId }, inputs => $"Creator ID: {inputs[0].Value}");
});

If you then have another migration for SomeType then it will work just fine with new serialized content containing Comment field.

Without data inputs you need to do it hacky way like

new ObjectInstanceMigration<SomeType, SomeType>(typeName, obj => {
    SimpleFixups.Add(() => obj.Comment = $"Creator ID: {obj.Creator.Value}");
});

It may look simpler, but it makes this migration incompatible with any further migration. I.e. if you then have new migration which uses Comment value for something else then you need to modify old migration to do the update in SimpleFixup block in addition to new migration to make it compatible with different save versions.

Inheritance
System.Object
DataInput
MemberDataInput
Implements
IDataInput
Namespace: Eco.Core.Serialization.Migrations.DataMigrations
Assembly: Eco.Core.dll
Syntax
public class DataInput : Object, IDataInput

Constructors

DataInput()

Declaration
public DataInput()

Methods

Member(String)

Input's member. Only valid for class/struct instance inputs.

Declaration
public MemberDataInput Member(string name)
Parameters
Type Name Description
System.String name
Returns
Type Description
MemberDataInput

ReferenceId()

Input's reference id. Only valid for inputs representing serialized references.

Declaration
public DataInput ReferenceId()
Returns
Type Description
DataInput

Implements

IDataInput

Extension Methods

PropertyChanges.FirePropertyChanged(Object, String)
PropertyChanges.FirePropertyChanged(Object, String, Object, Object)
PropertyChanges.FirePropertyChanged(Object, MemberChangedBeforeAfterEventArgs)
☀
☾
In This Article
Back to top
Copyright (c) Strange Loop Games 2021
☀
☾