コード例 #1
0
        public void Filter(MigrationFilterContext migrationFilterContext)
        {
            runnedRootIdentifier = dataProvider.GetData(rootKey);
            MigrationNodeStateInfo root;

            if (runnedRootIdentifier != null) //já possui root
            {
                root = migrationFilterContext.MigrationNodes.Where(x => x.MigrationNode.Identifier == runnedRootIdentifier).SingleOrDefault();
                if (root == null)
                {
                    throw new InvalidOperationException("The runned root node could not be found.");
                }
            }
            else //não possui root
            {
                root = migrationFilterContext.MigrationNodes.Where(x => x.MigrationNode.Root).LastOrDefault();
                if (root == null)
                {
                    root = migrationFilterContext.MigrationNodes.FirstOrDefault();
                    if (root == null)
                    {
                        throw new InvalidOperationException("Could not set a root node.");
                    }
                    runnedRootIdentifier = root.MigrationNode.Identifier;
                }
            }

            bool rootTouched = false;

            foreach (var item in migrationFilterContext.MigrationNodes)
            {
                if (item == root)
                {
                    rootTouched = true;
                }

                if (!rootTouched)
                {
                    foreach (var migration in item.MigrationsInfo)
                    {
                        migration.CurrentState = Migration.MigrationState.Filtered;
                    }
                }
            }
        }
コード例 #2
0
 public void Filter(MigrationFilterContext migrationFilterContext)
 {
     foreach (var node in migrationFilterContext.MigrationNodes)
     {
         List <IMigration> exceptMigrations = new List <IMigration>();
         foreach (var migration in node.MigrationsInfo.Select(x => x.Migration))
         {
             if (migration is IFlaggedMigration)
             {
                 var flags = ((IFlaggedMigration)migration).GetFlags();
                 if (!filter.Test(flags.ToArray()))
                 {
                     exceptMigrations.Add(migration);
                 }
             }
         }
         node.MigrationsInfo = node.MigrationsInfo.Where(x => !exceptMigrations.Contains(x.Migration)).ToList();
     }
 }
コード例 #3
0
 public void Filter(MigrationFilterContext migrationFilterContext)
 {
 }