/// <summary> /// Save a settings object to disk and update the settings cache. An empty object means create default settings file. /// </summary> /// <param name="settings">The settings object to save</param> public static void SaveSettings(Settings settings = null) { //check if we got the obj if (settings == null) { settings = new Settings { SiteName = "PodFull", TagLine = "Built for listening", DefaultMetaDescription = "Powered by https://github.com/jacobpretorius/PodFull", DefaultWindowTitle = $"PodFull | {ConfigurationManager.AppSettings["site-url"]}", RssTitle = "RSS FEED", RssUrl = "https://jcpretorius.com", iTunesTitle = "Listen on iTunes", iTunesUrl = "https://jcpretorius.com" }; } //save it try { var filePath = Path.Combine(_folder + "settings.config"); var saveSettings = new XDocument( new XElement("settings", new XElement("site_name", settings.SiteName), new XElement("tag_line", settings.TagLine), new XElement("window_title", settings.DefaultWindowTitle), new XElement("post_meta", settings.DefaultMetaDescription), new XElement("rss_title", settings.RssTitle), new XElement("rss_url", settings.RssUrl), new XElement("itunes_title", settings.iTunesTitle), new XElement("itunes_url", settings.iTunesUrl) )); //save to file saveSettings.Save(filePath); //add to cache (or update if exists) SettingsCache.SetSettings(settings); } catch { //todo log it } }
/// <summary> /// Save a settings object to disk and update the settings cache. An empty object means create default settings file. /// </summary> /// <param name="settings">The settings object to save</param> public static void SaveSettings(Settings settings = null) { //check if we got the obj if (settings == null) { settings = new Settings { BlogName = "BlogFull", TagLine = "Built for speed", DefaultMetaDescription = "Powered by https://github.com/jacobpretorius/BlogFull", DefaultWindowTitle = $"BlogFull | {ConfigurationManager.AppSettings["site-url"]}", AuthorName = "BlogFull" }; } //save it try { var filePath = Path.Combine(_folder + "settings.config"); var saveSettings = new XDocument( new XElement("settings", new XElement("blog_name", settings.BlogName), new XElement("tag_line", settings.TagLine), new XElement("window_title", settings.DefaultWindowTitle), new XElement("post_meta", settings.DefaultMetaDescription), new XElement("author_name", settings.AuthorName) )); //save to file saveSettings.Save(filePath); //add to cache (or update if exists) SettingsCache.SetSettings(settings); } catch { //todo log it } }