Пример #1
0
        private void LoadPatches()
        {
            DeepProfiler.Start("Loading all patches");
            patches          = new List <PatchOperation>();
            loadedAnyPatches = false;
            List <LoadableXmlAsset> list = DirectXmlLoader.XmlAssetsInModFolder(this, "Patches/").ToList();

            for (int i = 0; i < list.Count; i++)
            {
                XmlElement documentElement = list[i].xmlDoc.DocumentElement;
                if (documentElement.Name != "Patch")
                {
                    Log.Error($"Unexpected document element in patch XML; got {documentElement.Name}, expected 'Patch'");
                    continue;
                }
                foreach (XmlNode childNode in documentElement.ChildNodes)
                {
                    if (childNode.NodeType == XmlNodeType.Element)
                    {
                        if (childNode.Name != "Operation")
                        {
                            Log.Error($"Unexpected element in patch XML; got {childNode.Name}, expected 'Operation'");
                            continue;
                        }
                        PatchOperation patchOperation = DirectXmlToObject.ObjectFromXml <PatchOperation>(childNode, doPostLoad: false);
                        patchOperation.sourceFile = list[i].FullFilePath;
                        patches.Add(patchOperation);
                        loadedAnyPatches = true;
                    }
                }
            }
            DeepProfiler.End();
        }
 protected override bool ApplyWorker(XmlDocument xml)
 {
     foreach (PatchOperation patchOperation in this.operations)
     {
         if (!patchOperation.Apply(xml))
         {
             this.lastFailedOperation = patchOperation;
             return(false);
         }
     }
     return(true);
 }
Пример #3
0
        private void LoadPatches()
        {
            DeepProfiler.Start("Loading all patches");
            this.patches = new List <PatchOperation>();
            List <LoadableXmlAsset> list = DirectXmlLoader.XmlAssetsInModFolder(this, "Patches/").ToList <LoadableXmlAsset>();

            for (int i = 0; i < list.Count; i++)
            {
                XmlElement documentElement = list[i].xmlDoc.DocumentElement;
                if (documentElement.Name != "Patch")
                {
                    Log.Error(string.Format("Unexpected document element in patch XML; got {0}, expected 'Patch'", documentElement.Name));
                }
                else
                {
                    for (int j = 0; j < documentElement.ChildNodes.Count; j++)
                    {
                        XmlNode xmlNode = documentElement.ChildNodes[j];
                        if (xmlNode.NodeType == XmlNodeType.Element)
                        {
                            if (xmlNode.Name != "Operation")
                            {
                                Log.Error(string.Format("Unexpected element in patch XML; got {0}, expected 'Operation'", documentElement.ChildNodes[j].Name));
                            }
                            else
                            {
                                PatchOperation patchOperation = DirectXmlToObject.ObjectFromXml <PatchOperation>(xmlNode, false);
                                patchOperation.sourceFile = list[i].FullFilePath;
                                this.patches.Add(patchOperation);
                            }
                        }
                    }
                }
            }
            DeepProfiler.End();
        }
 public override void Complete(string modIdentifier)
 {
     base.Complete(modIdentifier);
     this.lastFailedOperation = null;
 }