using System.Xml.Linq; using InstaSoftOfficeTool.Models; namespace InstaSoftOfficeTool.Services { public static class OdtXmlGenerator { public static string Generate(InstallConfig config) { var product = new XElement("Product", new XAttribute("ID", config.Edition.ProductId)); if (!string.IsNullOrWhiteSpace(config.ProductKey)) { product.Add(new XAttribute("PIDKEY", config.ProductKey.Replace("-", "").Trim())); } product.Add(new XElement("Language", new XAttribute("ID", config.Language))); foreach (var app in config.ExcludedApps) { product.Add(new XElement("ExcludeApp", new XAttribute("ID", app))); } var add = new XElement("Add", new XAttribute("OfficeClientEdition", config.Architecture), new XAttribute("Channel", config.Edition.Channel), product); var configuration = new XElement("Configuration", add, new XElement("Display", new XAttribute("Level", "Full"), new XAttribute("AcceptEULA", "TRUE")), new XElement("Property", new XAttribute("Name", "FORCEAPPSHUTDOWN"), new XAttribute("Value", "TRUE"))); var doc = new XDocument(new XDeclaration("1.0", "utf-8", null), configuration); return doc.Declaration + "\n" + doc.Root; } public static string GenerateRemoveAll() { var configuration = new XElement("Configuration", new XElement("Remove", new XAttribute("All", "TRUE")), new XElement("Display", new XAttribute("Level", "Full"), new XAttribute("AcceptEULA", "TRUE"))); var doc = new XDocument(new XDeclaration("1.0", "utf-8", null), configuration); return doc.Declaration + "\n" + doc.Root; } } }