示例#1
0
        private string PrintTreeRecursive(ManifestTreeNode root, int level)
        {
            string content   = "";
            string tabString = "";

            for (int i = 0; i < level; i++)
            {
                tabString += "  ";
            }
            if (string.IsNullOrEmpty(root.nodeValue))
            {
                content += string.Format("{0}{1}\n", tabString, root.nodeKey);
            }
            else
            {
                content += string.Format("{0}{1}={2}\n", tabString, root.nodeKey, root.nodeValue);
            }

            if (root.left != null)
            {
                content += PrintTreeRecursive(root.left, level + 1);
            }
            if (root.right != null)
            {
                content += PrintTreeRecursive(root.right, level);
            }
            return(content);
        }
示例#2
0
 public ManifestDoc(string path)
 {
     root         = new ManifestTreeNode();
     root.Content = "Root";
     root.level   = -1;
     using (StreamReader sr = new StreamReader(path))
     {
         mAllLines = sr.ReadToEnd().Replace("\r\n", "\n").Split('\n');
         int start = 0;
         root.left = ParseNode(ref start, root);
     }
 }
示例#3
0
        public ManifestTreeNode this[string name]
        {
            get
            {
                ManifestTreeNode node = this.left;
                while (node != null)
                {
                    if (node.nodeKey.Equals(name))
                    {
                        return(node);
                    }

                    node = node.right;
                }
                return(null);
            }
        }
示例#4
0
        /// <summary>
        /// 初始化读取
        /// </summary>
        /// <param name="folder"></param>
        public static void ParseManifest(string folder)
        {
            if (sInfoList != null)
            {
                return;
            }

            sInfoList = new List <PackedBundleInfo>();
            ManifestDoc allDoc = new ManifestDoc(folder + "/bundlemap.bundle.manifest");

            ManifestTreeNode node = allDoc.root["AssetBundleManifest"]["AssetBundleInfos"];

            List <ManifestTreeNode> childList = node.Children;
            List <string>           valueList = new List <string>();

            for (int i = 0; i < childList.Count; i++)
            {
                ManifestDoc      singleDoc = new ManifestDoc(folder + "/" + childList[i]["Name"].nodeValue + ".manifest");
                PackedBundleInfo info      = new PackedBundleInfo();

                info.name = childList[i]["Name"].nodeValue;
                info.hash = singleDoc.root["Hashes"]["AssetFileHash"]["Hash"].nodeValue;


                List <ManifestTreeNode> assetList = singleDoc.root["Assets"].Children;
                valueList.Clear();
                for (int j = 0; j < assetList.Count; j++)
                {
                    valueList.Add(assetList[j].nodeKey);
                }
                info.assets = valueList.ToArray();


                List <ManifestTreeNode> depList = childList[i]["Dependencies"].Children;
                valueList.Clear();
                for (int j = 0; j < depList.Count; j++)
                {
                    valueList.Add(depList[j].nodeValue);
                }

                info.dependency = valueList.ToArray();

                sInfoList.Add(info);
            }
        }
示例#5
0
        private ManifestTreeNode ParseNode(ref int readIndex, ManifestTreeNode root)
        {
            if (readIndex >= mAllLines.Length)
            {
                return(null);
            }

            int treeLv = GetTreeLevel(mAllLines[readIndex]);

            if (treeLv < root.level)
            {
                return(null);
            }

            ManifestTreeNode node = new ManifestTreeNode();

            node.level   = treeLv;
            node.parent  = root;
            node.Content = mAllLines[readIndex];

            int nextLv = NextLineLevel(readIndex + 1);

            while (nextLv != -1)
            {
                if (nextLv > node.level)
                {
                    readIndex++;
                    node.left = ParseNode(ref readIndex, node);
                }
                else if (nextLv == node.level)
                {
                    readIndex++;
                    node.right = ParseNode(ref readIndex, root);
                }
                else
                {
                    return(node);
                }
                nextLv = NextLineLevel(readIndex + 1);
            }

            return(node);
        }