本文整理汇总了C#中IMigration.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IMigration.GetType方法的具体用法?C# IMigration.GetType怎么用?C# IMigration.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMigration
的用法示例。
在下文中一共展示了IMigration.GetType方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: 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);
}
}
示例3: Migrate
public override void Migrate(IMigration migration)
{
_provider.BeginTransaction();
MigrationAttribute attr = (MigrationAttribute)Attribute.GetCustomAttribute(migration.GetType(), typeof(MigrationAttribute));
var v = attr.GetVersion(migration.GetType());
var contains = false;
foreach (var appliedMigration in _provider.AppliedMigrations)
{
if (appliedMigration.Key != v.Key || appliedMigration.Value != v.Value) continue;
contains = true;
break;
}
if (contains)
{
RemoveMigration(migration, attr);
} else {
ApplyMigration(migration, attr);
}
}
示例4: Down
public void Down(IMigration migration)
{
var name = migration.GetType().Name;
_announcer.Heading(name + ": reverting");
CaughtExceptions = new List<Exception>();
var context = new MigrationContext(Conventions, Processor);
migration.GetDownExpressions(context);
_stopWatch.Start();
ExecuteExpressions(context.Expressions);
_stopWatch.Stop();
_announcer.Say(name + ": reverted");
_announcer.ElapsedTime(_stopWatch.ElapsedTime());
}
示例5: Down
public void Down(IMigration migration)
{
var name = migration.GetType().Name;
_announcer.Announce(name + ": reverting");
CaughtExceptions = new List<Exception>();
var context = new MigrationContext(Conventions,Processor);
migration.GetDownExpressions(context);
_stopWatch.Start();
ExecuteExpressions(context.Expressions);
_stopWatch.Stop();
var elapsed = _stopWatch.ElapsedTime().TotalSeconds;
_announcer.Announce(name + ": reverted (" + elapsed + "s" + ")");
}
示例6: ApplyConventionsToAndValidateExpressions
/// <summary>
/// Validates each migration expression that has implemented the ICanBeValidated interface.
/// It throws an InvalidMigrationException exception if validation fails.
/// </summary>
/// <param name="migration">The current migration being run</param>
/// <param name="expressions">All the expressions contained in the up or down action</param>
public void ApplyConventionsToAndValidateExpressions(IMigration migration, IEnumerable<IMigrationExpression> expressions)
{
var errorMessageBuilder = new StringBuilder();
foreach (var expression in expressions)
{
expression.ApplyConventions(_conventions);
var errors = new Collection<string>();
expression.CollectValidationErrors(errors);
if (errors.Count > 0)
AppendError(errorMessageBuilder, expression.GetType().Name, string.Join(" ", errors.ToArray()));
}
if (errorMessageBuilder.Length > 0)
{
var errorMessage = errorMessageBuilder.ToString();
_announcer.Error("The migration {0} contained the following Validation Error(s): {1}", migration.GetType().Name, errorMessage);
throw new InvalidMigrationException(migration, errorMessage);
}
}
示例7: GetMigrationName
private string GetMigrationName(IMigration migration)
{
if (migration == null) throw new ArgumentNullException("migration");
IMigrationMetadata metadata = migration as IMigrationMetadata;
if (metadata != null)
{
return string.Format("{0}: {1}", metadata.Version, metadata.Type.Name);
}
return migration.GetType().Name;
}
示例8: Up
public void Up(IMigration migration)
{
var name = GetMigrationName(migration);
_announcer.Heading(string.Format("{0} migrating", name));
CaughtExceptions = new List<Exception>();
var context = new MigrationContext(Conventions, Processor, Assembly.GetAssembly(migration.GetType()), ApplicationContext);
migration.GetUpExpressions(context);
_stopWatch.Start();
ExecuteExpressions(context.Expressions);
_stopWatch.Stop();
_announcer.Say(string.Format("{0} migrated", name));
_announcer.ElapsedTime(_stopWatch.ElapsedTime());
}
示例9: GetMigrationInfoFor
public static IMigrationInfo GetMigrationInfoFor(IMigration migration)
{
var migrationAttribute = migration.GetType().GetOneAttribute<MigrationAttribute>();
var migrationInfo = new MigrationInfo(migrationAttribute.Version, migrationAttribute.TransactionBehavior, migration);
foreach (MigrationTraitAttribute traitAttribute in migration.GetType().GetAllAttributes<MigrationTraitAttribute>())
migrationInfo.AddTrait(traitAttribute.Name, traitAttribute.Value);
return migrationInfo;
}
示例10: Up
public TimeSpan Up(IMigration migration)
{
var name = migration.GetType().Name;
_announcer.Heading(name + ": migrating");
CaughtExceptions = new List<Exception>();
var context = new MigrationContext(Conventions, Processor,MigrationAssembly);
migration.GetUpExpressions(context);
_stopWatch.Start();
ExecuteExpressions(context.Expressions);
_stopWatch.Stop();
_announcer.Say(name + ": migrated");
_announcer.ElapsedTime(_stopWatch.ElapsedTime());
return _stopWatch.ElapsedTime();
}
示例11: ApplyMigration
private void ApplyMigration(IMigration migration, MigrationAttribute attr)
{
// we're adding this one
_logger.MigrateUp(Current, migration.Name);
if(! DryRun)
{
migration.Up();
var v = attr.GetVersion(migration.GetType());
_provider.MigrationApplied(v.Value, v.Key);
_provider.Commit();
migration.AfterUp();
}
}
示例12: RemoveMigration
private void RemoveMigration(IMigration migration, MigrationAttribute attr)
{
// we're removing this one
_logger.MigrateDown(Current, migration.Name);
if (! DryRun)
{
migration.Down();
var v = attr.GetVersion(migration.GetType());
_provider.MigrationUnApplied(v.Value, v.Key);
_provider.Commit();
migration.AfterDown();
}
}
示例13: GetMigrationsAttributes
public static MigrationAttribute GetMigrationsAttributes(IMigration migration)
{
Trace.WriteLineIf(ts.TraceInfo, "MigrationService - GetMigrationsAttributes() - Start");
Attribute[] attrs = Attribute.GetCustomAttributes(migration.GetType());
MigrationAttribute results = null;
foreach (var attr in attrs)
{
if (attr is MigrationAttribute)
{
MigrationAttribute atr = attr as MigrationAttribute;
results = atr;
break;
}
}
Trace.WriteLineIf(ts.TraceInfo, "MigrationService - GetMigrationsAttributes() - End");
return results;
}