Esempio n. 1
0
        public void AddProjectXMLNode(string value)
        {
            if (ProjectXML == null)
            {
                string projectpath = EngineNS.CEngine.Instance.FileManager.ProjectSourceRoot + "Batman.Droid/";
                ProjectXML = EngineNS.IO.XmlHolder.LoadXML(projectpath + "Batman.Droid.csproj");

                CorrectProjectCatalogue(ProjectXML.RootNode);
            }
            EngineNS.IO.XmlNode ItemGroupNode    = ProjectXML.RootNode.AddNode("ItemGroup", "", ProjectXML);
            EngineNS.IO.XmlNode AndroidAssetNode = ItemGroupNode.AddNode("AndroidAsset", "", ProjectXML);

            //test
            value = value.Replace("/", "\\");
            AndroidAssetNode.AddAttrib("Include", value);
        }
Esempio n. 2
0
        public EngineNS.IO.XmlNode FindAndAddAssetNode(EngineNS.IO.XmlNode node, string name)
        {
            List <EngineNS.IO.XmlNode> nodes = node.GetNodes();

            foreach (var i in nodes)
            {
                //这里不能是空
                EngineNS.IO.XmlAttrib att = i.FindAttrib("Name");
                if (att != null && att.Value.Equals(name))
                {
                    return(i);
                }
            }

            EngineNS.IO.XmlNode sunnode = node.AddNode("Folder", "", AssetInfos);
            sunnode.AddAttrib("Name", name);

            return(sunnode);
        }
Esempio n. 3
0
        public void AddAssetInfos(string filename)
        {
            if (!System.IO.File.Exists(filename) || filename.EndsWith(".noused"))
            {
                return;
            }

            string allpath = EngineNS.CEngine.Instance.FileManager._GetRelativePathFromAbsPath(filename, EngineNS.CEngine.Instance.FileManager.CookingRoot);

            allpath = EngineNS.CEngine.Instance.FileManager.GetPathFromFullName(allpath, false);
            allpath = allpath.Replace("\\", "/");
            allpath = "Assets/" + allpath;
            string name = EngineNS.CEngine.Instance.FileManager.GetPureFileFromFullName(filename);

            string[]            folders = allpath.Split('/');
            EngineNS.IO.XmlNode node    = AssetInfos.RootNode;
            EngineNS.IO.XmlNode subnode;
            for (int i = 0; i < folders.Length; i++)
            {
                if (folders[i].Equals(""))
                {
                    break;
                }

                subnode = FindAndAddAssetNode(node, folders[i]);
                node    = subnode;
            }

            EngineNS.IO.XmlNode filenode = node.FindNode("Files");
            if (filenode == null)
            {
                filenode = node.AddNode("Files", "", AssetInfos);
            }

            foreach (var i in filenode.GetNodes())
            {
                if (i.FindAttrib("Name").Value == name)
                {
                    return;
                }
            }
            var value = filenode.AddNode("File", "", AssetInfos);

            value.AddAttrib("Name", name);

            //生成MD5码
            try
            {
                var MD5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
                System.IO.FileStream fs = new System.IO.FileStream(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read);
                byte[] code             = MD5.ComputeHash(fs);
                string str = System.Text.Encoding.ASCII.GetString(code);
                value.AddAttrib("MD5", System.Text.Encoding.ASCII.GetString(code));
                if (IsNeedProject)
                {
                    AddProjectXMLNode(allpath + name);
                }
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }
        }