/// <summary> /// Remove a CA from the Manager Configuration /// </summary> /// <param name="ca">CA object to remove</param> public void RemoveCA(CA ca) { // Remove the entry from the config file XDocument config = XDocument.Load(InitData.configFile); var calist = config.Element("OSCAMGR").Element("CAList").Descendants("CA"); foreach (XElement item in calist) { if (item.Element("name").Value == ca.CaName) { item.Remove(); break; // Have to break here as loop is unstable when last item removed from the list } } config.Save(InitData.configFile); // Remove the entry from the list CaList.Remove(ca); }
/// <summary> /// Add a new CA to the Manager Configuration /// </summary> /// <param name="ca">CA object to add</param> internal void InsertCA(CA ca) { // Create a new CA entry XElement entry = new XElement("CA", new XElement("name", ca.CaName), new XElement("type", ca.Role), new XElement("config", ca.ConfigLocation) ); // Insert CA entry into config file XDocument config = XDocument.Load(InitData.configFile); XElement ep = config.Element("OSCAMGR").Element("CAList"); ep.Add(entry); config.Save(InitData.configFile); // Insert CA entry into Config Manager object ca.CaControl = new CaControl(ca.ConfigLocation); CaList.Add(ca); }