Exemple #1
0
 /// <summary>
 /// Finds all valid implementations of <see cref="IMigration"/> in the
 /// specified <paramref name="assembly"/> and adds them to the migration process.
 /// </summary>
 /// <param name="assembly">The assembly to scan.</param>
 protected virtual void FindMigrations(Assembly assembly)
 {
     foreach (var type in assembly.GetTypes().Where(t => IsMigration(t)))
     {
         var attr = type.GetCustomAttributes(typeof(MigrationAttribute), false)[0] as MigrationAttribute;
         Migrations.Add(attr.Version, type);
     }
 }
Exemple #2
0
        /// <summary>
        /// Scan for implementations of the IMigration interface in the provided assembly and order by name
        /// </summary>
        public void ReadAssemblyMigrations(Assembly migrationAssembly)
        {
            //
            foreach (var exportedType in migrationAssembly.ExportedTypes)
            {
                if (exportedType.GetTypeInfo().GetInterfaces().Contains(typeof(IMigration)))
                {
                    var previousMigration = (IMigration)Activator.CreateInstance(exportedType);
                    Migrations.Add(previousMigration);
                }
            }

            Migrations = Migrations.OrderBy(m => m.Name).ToList();
        }
 protected virtual void RegisterMigration(Type type)
 {
     Migrations.Add(GetMigrationDateTime(type), type);
 }