Class Migration<T>
A generic migration represents an action or set of actions that need to be done to an object of type T
to update it to the game's current version.
Migrations are available for a multitude of object types that inhabit a Map, ExportedHousehold or ExportedLot by default.
Note that migrations do not have to be registered using Register<T>(IEnumerable<Migration<T>>) when added to a preexisting collection like Migrations or Migrations, but only when a mod adds a custom set of migrations for a custom object type.
public class Migration<T> : Migration
Type Parameters
T
- Inheritance
-
Migration<T>
- Inherited Members
- Extension Methods
Constructors
Migration(string, MigrationPhase, Action<T>)
Creates a new migration with the given settings.
public Migration(string name, MigrationPhase phase, Action<T> apply)
Parameters
name
stringThe name of this migration, which is stored in the save file or exported content once this migration has been applied if Silent is false.
phase
MigrationPhaseThe MigrationPhase that this migration should be applied on. Note that some object types only support the Single phase.
apply
Action<T>A function that applies this migration on an object. When using this constructor, Success is always returned in this migration's Apply function.
Migration(string, MigrationPhase, Func<T, IDictionary<string, JToken>, MigrationResult>)
Creates a new migration with the given settings.
public Migration(string name, MigrationPhase phase, Func<T, IDictionary<string, JToken>, MigrationResult> apply)
Parameters
name
stringThe name of this migration, which is stored in the save file or exported content once this migration has been applied if Silent is false.
phase
MigrationPhaseThe MigrationPhase that this migration should be applied on. Note that some object types only support the Single phase.
apply
Func<T, IDictionary<string, JToken>, MigrationResult>A function that applies this migration on an object. The passed JSON extension data is additional data that is loaded from disk, but didn't have an appropriate property or field to store it in. This can be useful for migrating objects whose property or field names changed, at which point relevant entries in the dictionary should be removed as part of this function.
Migration(string, MigrationPhase, Func<T, MigrationResult>)
Creates a new migration with the given settings.
public Migration(string name, MigrationPhase phase, Func<T, MigrationResult> apply)
Parameters
name
stringThe name of this migration, which is stored in the save file or exported content once this migration has been applied if Silent is false.
phase
MigrationPhaseThe MigrationPhase that this migration should be applied on. Note that some object types only support the Single phase.
apply
Func<T, MigrationResult>A function that applies this migration on an object.