コード例 #1
0
ファイル: BundleManager.cs プロジェクト: erxv/Wolven-kit
        /// <summary>
        ///     Rebuilds the bundle tree structure also rebuilds NOTE: Filelist,autocomplete,extensions
        /// </summary>
        public void RebuildRootNode()
        {
            RootNode = new BundleTreeNode();

            foreach (var item in Items)
            {
                var currentNode = RootNode;
                var parts       = item.Key.Split('\\');

                for (var i = 0; i < parts.Length - 1; i++)
                {
                    if (!currentNode.Directories.ContainsKey(parts[i]))
                    {
                        var newNode = new BundleTreeNode
                        {
                            Parent = currentNode,
                            Name   = parts[i]
                        };
                        currentNode.Directories.Add(parts[i], newNode);
                        currentNode = newNode;
                    }
                    else
                    {
                        currentNode = currentNode.Directories[parts[i]];
                    }
                }

                currentNode.Files.Add(parts[parts.Length - 1], item.Value);
            }
            RebuildFileList();
            RebuildExtensions();
            RebuildAutoCompleteSource();
        }
コード例 #2
0
 /// <summary>
 /// Deep search for files
 /// </summary>
 /// <param name="mainnode">The rootnode to get the files from</param>
 /// <returns></returns>
 public List<BundleItem> GetFiles(BundleTreeNode mainnode)
 {
     var bundfiles = new List<BundleItem>();
     if (mainnode?.Files != null)
     {
         foreach (var wfile in mainnode.Files)
         {
             bundfiles.AddRange(wfile.Value);
         }
         bundfiles.AddRange(mainnode.Directories.Values.SelectMany(GetFiles));
     }
     return bundfiles;
 }