Class AppliedMigrations
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
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
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
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
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
TThe object to apply the migrations on.
phase
MigrationPhaseThe migration phase to run.
Returns
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 passedphase
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
TThe object to apply the migrations on.
phase
MigrationPhaseThe 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. If all extension data is consumed by the migrations, this parameter is set to null automatically.
Returns
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 passedphase
is Single but a migration in the collection uses a different phase.