WriteFiles() public static method

public static WriteFiles ( MigrationFile files ) : void
files MigrationFile
return void
示例#1
0
        public static void Main(string[] args)
        {
            var allMigrations = new IMigration[] {
                new M0180(),
                new M0190(),
                new M0220(),
                new M0260(),
                new M0300(),
                new M0320()
            };

            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);
            }
        }
示例#2
0
        public static void Main(string[] args)
        {
            var allMigrations = Assembly
                                .GetAssembly(typeof(IMigration))
                                .GetTypes()
                                .Where(type => type.GetInterfaces().Contains(typeof(IMigration)))
                                .OrderBy(type => type.FullName)
                                .Select(type => (IMigration)Activator.CreateInstance(type))
                                .ToArray();

            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);
            }
        }