Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="info"></param>
        /// <param name="versionManager"></param>
        /// <param name="options"></param>
        private static void Migrate(CodeMigratorInfo info, ICodeMigrationVersionManager versionManager, ICodeMigrationOptions options)
        {
            options.Logger.Log($"Code migrator type {info.MigratorType} activate begin, with version {info.MigratorVersion}");
            var migrator = options.Activator.Activate(info.MigratorType);

            options.Logger.Log($"Code migrator type {info.MigratorType} activate end, with version {info.MigratorVersion}");

            options.Logger.Log($"Code migrator type {info.MigratorType} migrate begin, with version {info.MigratorVersion}");
            migrator.Migrate();
            options.Logger.Log($"Code migrator type {info.MigratorType} migrate end, with version {info.MigratorVersion}");

            versionManager.SetVersion(info.MigratorVersion);
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="migratorType"></param>
        /// <returns></returns>
        private static CodeMigratorInfo GetMigrator(Type migratorType)
        {
            var attr = migratorType.GetCustomAttribute <CodeMigrationAttribute>();

            if (attr == null)
            {
                return(null);
            }

            var info = new CodeMigratorInfo();

            info.MigratorVersion = Version.Parse(attr.Version);
            info.MigratorType    = migratorType;

            return(info);
        }