Пример #1
0
        private void CleanFolder(FolderItem folder)
        {
            if (folder.SubDirs != null && folder.SubDirs.Count > 0)
            {
                for (var i = folder.SubDirs.Count - 1; i >= 0; i--)
                {
                    CleanFolder(folder.SubDirs[i]);
                }
//                folder.SubDirs = null;
            }
            if (folder.Projects != null)
            {
                for (var i = folder.Projects.Count - 1; i >= 0; i--)
                {
                    var project        = folder.Projects[i];
                    var collectionItem = _collectionItems.FirstOrDefault(ci => ci.Project == project);
                    if (collectionItem != null)
                    {
                        RemoveItem(collectionItem, false);
                    }
                }
            }
        }
Пример #2
0
 private FolderItem GetDir(FolderItem parentItem, string[] createdPath, int currentIndex)
 {
     if (parentItem.SubDirs != null)
     {
         foreach (var item in parentItem.SubDirs)
         {
             if (string.Equals((item.Name), createdPath[currentIndex], StringComparison.CurrentCultureIgnoreCase))
             {
                 if (currentIndex == createdPath.Length - 1)
                 {
                     return item;
                 }
                 return GetDir(item, createdPath, currentIndex + 1);
             }
         }
     }
     else
     {
         parentItem.SubDirs = new List<FolderItem>();
     }
     // Если не найдено, создаём каталог
     var fullPath = _projectCollection.RootDir;
     for (var i = 0; i < currentIndex; i++)
     {
         fullPath = Path.Combine(fullPath, createdPath[i]);
     }
     for (var i = currentIndex; i < createdPath.Length; i++)
     {
         fullPath = Path.Combine(fullPath, createdPath[i]);
         var curItem = new FolderItem
         {
             Parent = parentItem,
             Name = createdPath[i],
             FullPath = fullPath,
             SubDirs = new List<FolderItem>()
         };
         parentItem.SubDirs.Add(curItem);
         parentItem = curItem;
     }
     return parentItem;
 }
Пример #3
0
        private void CleanFolder(FolderItem folder)
        {
            if (folder.SubDirs != null && folder.SubDirs.Count > 0)
            {
                for (var i = folder.SubDirs.Count - 1; i >= 0; i--)
                {
                    CleanFolder(folder.SubDirs[i]);
                }
//                folder.SubDirs = null;
            }
            if (folder.Projects != null)
            {
                for (var i = folder.Projects.Count - 1; i >= 0; i--)
                {
                    var project = folder.Projects[i];
                    var collectionItem = _collectionItems.FirstOrDefault(ci => ci.Project == project);
                    if (collectionItem != null)
                        RemoveItem(collectionItem, false);
                }
            }
        }