Ejemplo n.º 1
0
        private static bool TransformInternal(VirtualFolder root, VirtualFolder current)
        {
            foreach (var f in current.ChildFolders.ToList()) {
            var vf = f as VirtualFolder;
            if (TransformInternal(root, vf)) {
              current.ReleaseFolder(vf);
            }
              }

              if (current == root || current.ChildItems.Count() > 3) {
            return false;
              }
              var newParent = current.Parent as VirtualFolder;
              foreach (var c in current.ChildItems.ToList()) {
            current.RemoveResource(c);
            newParent.AddResource(c);
              }

              if (current.ChildCount != 0) {
            MergeFolders(current, newParent);
            foreach (var f in current.ChildFolders.ToList()) {
              newParent.AdoptFolder(f);
            }
            foreach (var f in current.ChildItems.ToList()) {
              current.RemoveResource(f);
              newParent.AddResource(f);
            }
              }
              return true;
        }
Ejemplo n.º 2
0
        private static bool TransformInternal(VirtualFolder root,
                                              VirtualFolder current)
        {
            foreach (var f in current.ChildFolders.ToList())
            {
                var vf = f as VirtualFolder;
                if (TransformInternal(root, vf))
                {
                    current.ReleaseFolder(vf);
                }
            }

            if (current == root || current.ChildItems.Count() > 3)
            {
                return(false);
            }
            var newParent = (VirtualFolder)current.Parent;

            foreach (var c in current.ChildItems.ToList())
            {
                current.RemoveResource(c);
                newParent.AddResource(c);
            }

            if (current.ChildCount != 0)
            {
                MergeFolders(current, newParent);
                foreach (var f in current.ChildFolders.ToList())
                {
                    newParent.AdoptFolder(f);
                }
                foreach (var f in current.ChildItems.ToList())
                {
                    current.RemoveResource(f);
                    newParent.AddResource(f);
                }
            }

            return(true);
        }