Table of Contents

Class AppliedMigrations

Namespace
TinyLife.Utilities
Assembly
Tiny Life.dll

A class that handles the application of Migration actions on objects that are being validated or loaded from disk.

public class AppliedMigrations
Inheritance
AppliedMigrations
Inherited Members
Extension Methods

Fields

Done

Returns a new AppliedMigrations instance that already has all migrations marked as applied.

public static readonly AppliedMigrations Done

Field Value

AppliedMigrations

Silent

Returns a new AppliedMigrations instance that only applies migrations that are Silent, meaning no migration names will be stored.

public static readonly AppliedMigrations Silent

Field Value

AppliedMigrations

Methods

ApplyWithData(ref HashSet<string>)

Returns a new applied migration handler that only applies migrations that haven't already been applied. Migrations that have previously been applied should be passed in the applied parameter, and the resulting collection will be updated with the names of the migrations that have been applied.

public static AppliedMigrations ApplyWithData(ref HashSet<string> applied)

Parameters

applied HashSet<string>

The set of migrations that have already been applied.

Returns

AppliedMigrations

The newly created applied migration handler.

DoneNames()

Returns a set of all names of all Migrations that aren't Silent, which is used as the default value for AppliedMigrations, AppliedMigrations and AppliedMigrations to signify that all migrations have already been applied in a new map or exported content item.

public static HashSet<string> DoneNames()

Returns

HashSet<string>

The set of all migration names that aren't silent.

Migrate<T>(ICollection<Migration<T>>, T, MigrationPhase)

Migrates the given object with type T using the given set of migrations. If a migration returns the Failure result, this method returns false, implying that the object being migrated is invalid.

public bool Migrate<T>(ICollection<Migration<T>> migrations, T obj, MigrationPhase phase)

Parameters

migrations ICollection<Migration<T>>

The migrations to apply.

obj T

The object to apply the migrations on.

phase MigrationPhase

The migration phase to run.

Returns

bool

Whether the migration was successful. If false, the object should be marked as invalid.

Type Parameters

T

The type of object to migrate.

Exceptions

InvalidOperationException

Thrown when only silent migrations can be applied and a nonsilent migration is contained in migrations, or when the passed phase is Single but a migration in the collection uses a different phase.

Migrate<T>(ICollection<Migration<T>>, T, MigrationPhase, ref IDictionary<string, JToken>)

Migrates the given object with type T using the given set of migrations. If a migration returns the Failure result, this method returns false, implying that the object being migrated is invalid.

public bool Migrate<T>(ICollection<Migration<T>> migrations, T obj, MigrationPhase phase, ref IDictionary<string, JToken> jsonExtensionData)

Parameters

migrations ICollection<Migration<T>>

The migrations to apply.

obj T

The object to apply the migrations on.

phase MigrationPhase

The migration phase to run.

jsonExtensionData IDictionary<string, JToken>

The object's JSON extension data, which 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.

Returns

bool

Whether the migration was successful. If false, the object should be marked as invalid.

Type Parameters

T

The type of object to migrate.

Exceptions

InvalidOperationException

Thrown when only silent migrations can be applied and a nonsilent migration is contained in migrations, or when the passed phase is Single but a migration in the collection uses a different phase.