本文整理汇总了C#中IMigration类的典型用法代码示例。如果您正苦于以下问题:C# IMigration类的具体用法?C# IMigration怎么用?C# IMigration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IMigration类属于命名空间,在下文中一共展示了IMigration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: printAllMigrations
static void printAllMigrations(IMigration[] migrations) {
foreach (var m in migrations) {
Console.WriteLine("========================================");
Console.WriteLine(m.version + "\n - " + m.description + "\n - Use on folder, " + m.workingDirectory);
}
Console.WriteLine("========================================");
}
示例2: MigrationWithMetaDataAdapter
public MigrationWithMetaDataAdapter(IMigration migration, IMigrationMetadata metadata)
{
if (migration == null) throw new ArgumentNullException("migration");
if (metadata == null) throw new ArgumentNullException("metadata");
Migration = migration;
MetaData = metadata;
}
示例3: migrate
static void migrate(IMigration migration)
{
var shouldMigrate = EditorUtility.DisplayDialog("Migrate",
"You are about to migrate your source files. " +
"Make sure that you have committed your current project or that you have a backup of your project before you proceed.",
"I have a backup - Migrate",
"Cancel"
);
if(shouldMigrate) {
EditorUtility.DisplayDialog("Migrate",
"Please select the folder, " + migration.workingDirectory + ".",
"I will select the requested folder"
);
var path = "Assets/";
path = EditorUtility.OpenFolderPanel(migration.version + ": " + migration.workingDirectory, path, string.Empty);
if(!string.IsNullOrEmpty(path)) {
var changedFiles = migration.Migrate(path);
Debug.Log("Applying " + migration.version);
foreach(var file in changedFiles) {
MigrationUtils.WriteFiles(changedFiles);
Debug.Log("Migrated " + file.fileName);
}
} else {
throw new Exception("Could not complete migration! Selected path was invalid!");
}
}
}
示例4: printUsage
static void printUsage(IMigration[] migrations)
{
Console.WriteLine(@"usage:
[-l] - print all available versions
[version] [path] - apply migration of version [version] to source files located at [path]"
);
}
示例5: Main
public static void Main(string[] args)
{
var allMigrations = new IMigration[] {
new M0180(),
new M0190(),
new M0220(),
new M0260(),
new M0300()
};
if (args == null) {
printUsage(allMigrations);
} else if (args.Length == 1) {
var arg = args[0];
if (arg == "-l") {
printAllMigrations(allMigrations);
} else {
printUsage(allMigrations);
}
} else if (args.Length == 2) {
var version = args[0];
var path = args[1];
var migrations = allMigrations.Where(m => m.version == version).ToArray();
if (migrations.Length == 0) {
printVersionNotFound(version, allMigrations);
} else {
foreach (var m in migrations) {
MigrationUtils.WriteFiles(m.Migrate(path));
}
}
} else {
printUsage(allMigrations);
}
}
示例6: AfterMigrationEventArgs
/// <summary>
/// Initializes a new instance of the <see cref="AfterMigrationEventArgs"/> class.
/// </summary>
/// <param name="version">The version.</param>
/// <param name="migration">The migration.</param>
/// <param name="direction">The direction.</param>
/// <param name="success">if set to <c>true</c> the migration succeeded.</param>
public AfterMigrationEventArgs(long version, IMigration migration, MigrationDirection direction, bool success)
{
Version = version;
Migration = migration;
Direction = direction;
Success = success;
}
示例7: ExtractTimestamp
private long ExtractTimestamp(string moduleName, IMigration migration)
{
var timestampProvider = _timestampProviders.ContainsKey(moduleName)
? _timestampProviders[moduleName]
: _timestampProviders[MigrationExportAttribute.DefaultModuleName];
long timestamp = timestampProvider.GetTimestamp(migration.GetType());
return timestamp;
}
示例8: MigrationStep
public MigrationStep(IMigration migration, IScheduledMigrationMetadata metadata, ConnectionInfo connectionInfo, IProvider provider, IProviderMetadata providerMetadata, IDbConnectionFactory connectionFactory, ISqlDispatcher sqlDispatcher)
: base(migration, provider, providerMetadata)
{
_metadata = metadata;
_connectionInfo = connectionInfo;
_connectionFactory = connectionFactory;
_sqlDispatcher = sqlDispatcher;
}
示例9: MigrationInfo
public MigrationInfo(long version, TransactionBehavior transactionBehavior, IMigration migration)
{
if (migration == null) throw new ArgumentNullException("migration");
Version = version;
TransactionBehavior = transactionBehavior;
Migration = migration;
}
示例10: MigrationInfo
public MigrationInfo(long version, TransactionBehavior transactionBehavior, bool breakingChange, IMigration migration)
{
if (migration == null) throw new ArgumentNullException("migration");
Version = version;
TransactionBehavior = transactionBehavior;
Migration = migration;
BreakingChange = breakingChange;
}
示例11: ApplyMigration
private void ApplyMigration(IMigration migration, MigrationAttribute attr) {
// we're adding this one
_logger.MigrateUp(Current, migration.Name);
if (! DryRun) {
migration.Up();
_provider.MigrationApplied(attr.Version);
_provider.Commit();
migration.AfterUp();
}
}
示例12: MigrationVersionRunner
public MigrationVersionRunner(IMigrationConventions conventions, IMigrationProcessor processor, IMigrationLoader loader, Assembly assembly, string @namespace)
{
_migrationConventions = conventions;
_migrationProcessor = processor;
_migrationAssembly = assembly;
_migrationLoader = loader;
_namespace = @namespace;
_migrationRunner = new MigrationRunner(conventions, processor);
_versionMigration = new VersionMigration();
}
示例13: RemoveMigration
private void RemoveMigration(IMigration migration, MigrationAttribute attr) {
// we're removing this one
_logger.MigrateDown(Current, migration.Name);
if (! DryRun) {
migration.Down();
_provider.MigrationUnApplied(attr.Version);
_provider.Commit();
migration.AfterDown();
}
}
示例14: Migrate
public override void Migrate(IMigration migration)
{
_provider.BeginTransaction();
MigrationAttribute attr = (MigrationAttribute)Attribute.GetCustomAttribute(migration.GetType(), typeof(MigrationAttribute));
if (_provider.AppliedMigrations.Contains(attr.Version)) {
RemoveMigration(migration, attr);
} else {
ApplyMigration(migration, attr);
}
}
示例15: SolveDependency
private void SolveDependency(IDbRoot root, string filePath, IMigration migration)
{
foreach (var migrationId in migration.MigrationsNeeded.Where(x => !root.MigrationHistory.HasMigration(x)))
{
// For each dependency that needs to be solved, we solve the subdependencies
var dependency = this.migrations[migrationId];
this.SolveDependency(root, filePath, dependency);
dependency.Apply(root, filePath);
root.MigrationHistory.AddMigration(migrationId);
}
}