private void RemoveManifest(IMod p_modMod)
        {
            string profilesDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"Larian Studios\Baldur's Gate 3\PlayerProfiles");

            if (Directory.Exists(profilesDirectory))
            {
                DirectoryInfo diProfiles = new DirectoryInfo(profilesDirectory);

                foreach (DirectoryInfo dir in diProfiles.GetDirectories())
                {
                    if (!dir.Name.Equals("default", StringComparison.OrdinalIgnoreCase))
                    {
                        string manifest = Path.Combine(dir.FullName, "modsettings.lsx");

                        if (File.Exists(manifest))
                        {
                            XmlDocument XDoc = new XmlDocument();
                            XDoc.Load(manifest);
                            XmlNode xmlMods     = XDoc.DocumentElement.SelectSingleNode("//*[@id='Mods']");
                            XmlNode xmlChildren = xmlMods.FirstChild;
                            BG3Json currentMod  = LoadJson(Encoding.ASCII.GetString(p_modMod.GetFile("info.json")));

                            foreach (BG3Mod mod in currentMod.Mods)
                            {
                                XmlNode xmlMod = XDoc.DocumentElement.SelectSingleNode("//*[@value='" + mod.UUID + "']");

                                if (xmlMod != null)
                                {
                                    XmlNode parent = xmlMod.ParentNode;
                                    xmlChildren.RemoveChild(parent);
                                }
                            }

                            XmlWriterSettings settings = new XmlWriterSettings();
                            settings.Indent      = true;
                            settings.IndentChars = "\t";
                            using (XmlWriter writer = XmlWriter.Create(manifest, settings))
                            {
                                XDoc.Save(writer);
                            }
                        }
                    }
                }
            }
        }
        public BG3Json LoadJson(string json)
        {
            BG3Json items = JsonConvert.DeserializeObject <BG3Json>(json);

            return(items);
        }
        private void AddManifest(IMod p_modMod)
        {
            string profilesDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"Larian Studios\Baldur's Gate 3\PlayerProfiles");

            if (Directory.Exists(profilesDirectory))
            {
                DirectoryInfo diProfiles = new DirectoryInfo(profilesDirectory);

                foreach (DirectoryInfo dir in diProfiles.GetDirectories())
                {
                    if (!dir.Name.Equals("default", StringComparison.OrdinalIgnoreCase))
                    {
                        string manifest = Path.Combine(dir.FullName, "modsettings.lsx");

                        if (File.Exists(manifest))
                        {
                            XmlDocument XDoc = new XmlDocument();
                            XDoc.Load(manifest);
                            XmlNode xmlMods     = XDoc.DocumentElement.SelectSingleNode("//*[@id='Mods']");
                            XmlNode xmlChildren = xmlMods.FirstChild;
                            BG3Json currentMod  = LoadJson(Encoding.ASCII.GetString(p_modMod.GetFile("info.json")));

                            foreach (BG3Mod mod in currentMod.Mods)
                            {
                                XmlNode xmlCheck = XDoc.DocumentElement.SelectSingleNode("//*[@value='" + mod.UUID + "']");

                                if (xmlCheck == null)
                                {
                                    XmlElement modDesc = XDoc.CreateElement("node");
                                    modDesc.SetAttribute("id", "ModuleShortDesc");
                                    XmlElement attribute = XDoc.CreateElement("attribute");
                                    attribute.SetAttribute("id", "Folder");
                                    attribute.SetAttribute("type", "LSString");
                                    attribute.SetAttribute("value", mod.Folder);
                                    modDesc.AppendChild(attribute);
                                    attribute = XDoc.CreateElement("attribute");
                                    attribute.SetAttribute("id", "MD5");
                                    attribute.SetAttribute("type", "LSString");
                                    attribute.SetAttribute("value", string.Empty);
                                    modDesc.AppendChild(attribute);
                                    attribute = XDoc.CreateElement("attribute");
                                    attribute.SetAttribute("id", "Name");
                                    attribute.SetAttribute("type", "LSString");
                                    attribute.SetAttribute("value", mod.Name);
                                    modDesc.AppendChild(attribute);
                                    attribute = XDoc.CreateElement("attribute");
                                    attribute.SetAttribute("id", "UUID");
                                    attribute.SetAttribute("type", "FixedString");
                                    attribute.SetAttribute("value", mod.UUID);
                                    modDesc.AppendChild(attribute);
                                    attribute = XDoc.CreateElement("attribute");
                                    attribute.SetAttribute("id", "Version64");
                                    attribute.SetAttribute("type", "int64");
                                    attribute.SetAttribute("value", mod.Version ?? "1");
                                    modDesc.AppendChild(attribute);
                                    xmlChildren.AppendChild(modDesc);
                                }
                            }

                            XmlWriterSettings settings = new XmlWriterSettings();
                            settings.Indent      = true;
                            settings.IndentChars = "\t";
                            using (XmlWriter writer = XmlWriter.Create(manifest, settings))
                            {
                                XDoc.Save(writer);
                            }
                        }
                    }
                }
            }
        }