private static void addSettingsDocToCache(ObjectCache cache, DTO.Enums.BackEndOrFrontEndEnum whichEnd) { CacheItemPolicy policy = createCacheItemPolicy(GetPath.GetSettingsXMLPath(whichEnd)); var doc = new XmlDocument(); try { doc.Load(GetPath.GetSettingsXMLPath(whichEnd)); } catch (FileNotFoundException) { System.Exception newException = null; switch (whichEnd) { case DTO.Enums.BackEndOrFrontEndEnum.BackEnd: newException = new DTO.Exceptions.BackEndSettingsNotFoundException(); break; case DTO.Enums.BackEndOrFrontEndEnum.FrontEnd: newException = new DTO.Exceptions.FrontEndSettingsNotFoundException(); break; } throw newException; } catch (Exception) { throw; } cache.Set(Enum.GetName(typeof(DTO.Enums.BackEndOrFrontEndEnum), whichEnd) + "SettingsDoc", doc, policy); }
//This will set the front end version number to zero, thus requiring that it be updated next launch. public static void SetFrontEndVersionToZero() { var doc = GetXmlDoc.GetFrontEndXmlDoc(); doc.SelectSingleNode("//CurrentVersion").InnerText = "0"; doc.Save(GetPath.GetSettingsXMLPath(DTO.Enums.BackEndOrFrontEndEnum.FrontEnd)); }
//This is a special method used for saving the Front End Doc, which will raise a special custom //exception if it cannot. internal static void saveFrontEndDoc(XmlDocument doc) { saveDoc(GetPath.GetSettingsXMLPath(DTO.Enums.BackEndOrFrontEndEnum.FrontEnd), new DTO.Exceptions.CouldNotSaveFrontEndXmlDocException(), doc); }