Exemplo n.º 1
0
 private void AssertNoChildren(Ent ent, List <string> path, List <Op> ops)
 {
     Info.TypeEn subbecomes = MergeRecurseSubs(ent, path, ops);
     if (subbecomes != 0)
     {
         throw new CannotHappenException("Should delete all siblings but for some of them children remain.");
     }
 }
Exemplo n.º 2
0
        private Info.TypeEn MergeRecurse(Ent ent, List <string> path, List <Op> ops)
        {
            Info.TypeEn becomes = 0;
            if (ent.ActualWinner == WinnerPreserve)
            {
                for (int i = 0; i < MaxConnCount; i++)
                {
                    if (ent.Infos[i] != null)
                    {
                        becomes |= ent.Infos[i].Type;
                    }
                }
                if (0 == (becomes & ~(Info.TypeEn.Dir | Info.TypeEn.Other)))
                {
                    MergeRecurseSubs(ent, path, ops);
                }
                else
                {
                    AssertNoChildren(ent, path, ops);
                }
            }
            else
            {
                becomes = ent.Infos[ent.ActualWinner].Type;
                Info.AssertValidType(becomes);
                switch (becomes)
                {
                case Info.TypeEn.None:
                    AssertNoChildren(ent, path, ops);
                    MapInfosThatExist(ent, delegate(int i) {
                        AddEntOpsWhenNoneWins(ent, path, ops, i);
                    });
                    break;

                case Info.TypeEn.File:
                    AssertNoChildren(ent, path, ops);
                    MapInfosThatExist(ent, delegate(int i) {
                        AddEntOpsWhenFileWins(ent, path, ops, i);
                    });
                    break;

                case Info.TypeEn.Dir:
                    MapInfosThatExist(ent, delegate(int i) {
                        AddEntOpsWhenDirWins(ent, path, ops, i);
                    });
                    MergeRecurseSubs(ent, path, ops);
                    break;

                case Info.TypeEn.Other:
                    MapInfosThatExist(ent, delegate(int i) {
                        AddEntOpsWhenOtherWins(ent, i);
                    });
                    break;
                }
            }
            return(becomes);
        }
Exemplo n.º 3
0
 private Info.TypeEn MergeRecurseSubs(Ent ent, List <string> path, List <Op> ops)
 {
     Info.TypeEn subbecomes = 0;
     if (ent.Node.Parent != null)
     {
         path.Add(ent.Name);
     }
     foreach (TreeNode subnode in ent.Node.Nodes)
     {
         Ent subent = (Ent)subnode.Tag;
         subbecomes |= MergeRecurse(subent, path, ops);
     }
     if (ent.Node.Parent != null)
     {
         path.RemoveAt(path.Count - 1);
     }
     return(subbecomes);
 }