Пример #1
0
 public static void GetAllChildFolders(TreeNode node, List<string> result)
 {
     if (node.Folder != null)
     {
         result.Add(node.Folder.FolderId);
         foreach (var child in node.Childrens)
         {
             GetAllChildFolders(child, result);
         }
     }
 }
Пример #2
0
 public static TreeNode FindFolderId(TreeNode node, string folderId)
 {
     if (node.FolderId == folderId)
         return node;
     foreach (var child in node.Childrens)
     {
         var result = FindFolderId(child, folderId);
         if (result != null)
             return result;
     }
     return null;
 }
Пример #3
0
 public static List<string> GetAllFoldersAndChildFolders(TreeNode root, List<string> folderIds)
 {
     HashSet<string> result = new HashSet<string>(folderIds);
     foreach (var id in folderIds)
     {
         var eachResult = GetAllFoldersAndChildFolders(root, id);
         foreach (var eachid in eachResult)
         {
             if (!result.Contains(eachid))
             {
                 result.Add(eachid);
             }
         }
     }
     return result.ToList();
 }
Пример #4
0
 public static void DepthFirstTraverseTree(TreeNode root, FuncForDealEachNodeWhenDepthFirstTraverse func)
 {
     DepthFirstTraverseTree(root, 0, func);
 }
Пример #5
0
 private static void DepthFirstTraverseTree(TreeNode node, int depth, FuncForDealEachNodeWhenDepthFirstTraverse func)
 {
     int childCount = 0;
     foreach(var child in node.Childrens)
     {
         DepthFirstTraverseTree(child, depth + 1, func);
         childCount++;
     }
     if (func != null)
         func(node, depth, childCount);
 }
Пример #6
0
 private static void TraverseTree(TreeNode child, Dictionary<string, List<IFolderDataBase>> result, List<IFolderDataBase> paths)
 {
     result.Add(child.Folder.FolderId, paths);
     var children = child.Childrens;
     if (children.Count > 0)
     {
         foreach (var node in children)
         {
             var childpaths = new List<IFolderDataBase>();
             childpaths.AddRange(paths);
             childpaths.Add(node.Folder);
             TraverseTree(node, result, childpaths);
         }
     }
 }
Пример #7
0
 private static TreeNode CreateOrGetParentNode(string parentId, Dictionary<string, TreeNode> folderId2Node)
 {
     TreeNode result = null;
     if (!folderId2Node.TryGetValue(parentId, out result))
     {
         result = new TreeNode();
         folderId2Node.Add(parentId, result);
     }
     result.FolderId = parentId;
     return result;
 }
Пример #8
0
 private static TreeNode CreateNode(IFolderData folder, Dictionary<string, TreeNode> folderId2Node)
 {
     TreeNode result = null;
     if (!folderId2Node.TryGetValue(folder.FolderId, out result))
     {
         result = new TreeNode();
         folderId2Node.Add(folder.FolderId, result);
     }
     result.Folder = folder;
     result.FolderId = folder.FolderId;
     return result;
 }
Пример #9
0
        public static Dictionary<string, List<IFolderDataBase>> GetEachFolderPath(TreeNode root)
        {
            Dictionary<string, List<IFolderDataBase>> result = new Dictionary<string, List<IFolderDataBase>>();
            List<IFolderDataBase> paths = new List<IFolderDataBase>();

            var children = root.Childrens;
            foreach (var node in children)
            {
                paths = new List<IFolderDataBase>();
                paths.Add(node.Folder);
                TraverseTree(node, result, paths);
            }
            return result;
        }
Пример #10
0
 public static List<string> GetAllFoldersAndChildFolders(TreeNode root, string folderId)
 {
     var findNode = FindFolderId(root, folderId);
     if (findNode == null)
         throw new NullReferenceException(string.Format("can't find folder [{0}]", folderId));
     var result = new List<string>();
     GetAllChildFolders(findNode, result);
     return result;
 }
Пример #11
0
 internal MailboxFolderTreePath(string mailboxAddress, Dictionary<string, List<IFolderDataBase>> folderPaths, TreeNode root)
 {
     MailboxAddress = mailboxAddress;
     FolderPaths = folderPaths;
     Root = root;
 }