当前位置: 首页>>代码示例>>C#>>正文


C# IMigration.GetType方法代码示例

本文整理汇总了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;
 }
开发者ID:dradovic,项目名称:MigSharp,代码行数:8,代码来源:MigrationImporter.cs

示例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);
     }
 }
开发者ID:X0nic,项目名称:Migrator.NET,代码行数:11,代码来源:MigrateAnywhere.cs

示例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);
            }
        }
开发者ID:acropolium,项目名称:Migrator.NET,代码行数:22,代码来源:MigrateAnywhere.cs

示例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());
        }
开发者ID:paulbatum,项目名称:fluentmigrator,代码行数:17,代码来源:MigrationRunner.cs

示例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" + ")");
        }
开发者ID:ngbrown,项目名称:fluentmigrator,代码行数:20,代码来源:MigrationRunner.cs

示例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);
            }
        }
开发者ID:BhuvanB,项目名称:fluentmigrator,代码行数:28,代码来源:MigrationValidator.cs

示例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;
        }
开发者ID:Pathoschild,项目名称:fluentmigrator,代码行数:11,代码来源:MigrationRunner.cs

示例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());
        }
开发者ID:MikeBagos,项目名称:fluentmigrator,代码行数:17,代码来源:MigrationRunner.cs

示例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;
        }
开发者ID:patrickbird,项目名称:fluentmigrator,代码行数:10,代码来源:DefaultMigrationConventions.cs

示例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();
        }
开发者ID:mgaspar,项目名称:fluentmigrator,代码行数:19,代码来源:MigrationRunner.cs

示例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();
     }
 }
开发者ID:acropolium,项目名称:Migrator.NET,代码行数:13,代码来源:MigrateAnywhere.cs

示例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();
     }
 }
开发者ID:acropolium,项目名称:Migrator.NET,代码行数:13,代码来源:MigrateAnywhere.cs

示例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;
        }
开发者ID:Mission3,项目名称:migrations,代码行数:19,代码来源:MigrationService.cs


注:本文中的IMigration.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。