/// <summary> /// Clone constructor for the PageSettings class /// </summary> /// <param name="pageSettings">The PageSettings object to copy the properties of</param> private PageSettings(PageSettings pageSettings) { Title = pageSettings.Title; Description = pageSettings.Description; Keywords = pageSettings.Keywords; Creator = pageSettings.Creator; SiteTitle = pageSettings.SiteTitle; TopNavDisplay = pageSettings.TopNavDisplay; MenuNavDisplay = pageSettings.MenuNavDisplay; GlobalNavDisplay = pageSettings.GlobalNavDisplay; SideContentDisplay = pageSettings.SideContentDisplay; Menu = pageSettings.Menu; #if DEBUG Menu = new MenuHelper("~/Menu.json", ConfigurationManager.AppSettings); #endif Classifications = new List<Classification>(pageSettings.Classifications); DateCreated = pageSettings.DateCreated; DateModified = pageSettings.DateModified; }
/// <summary> /// Constructor for the PageSettings class; loads data from the Metadata section of /// the config file /// </summary> private PageSettings() { Classifications = new List<Classification>(); if (_metaDataSection == null) { _metaDataSection = (NameValueCollection)ConfigurationManager.GetSection("Metadata") ?? new NameValueCollection(); } // Set string metadata from the config Title = GetConfigItem(ref _metaDataSection, "Title"); Description = GetConfigItem(ref _metaDataSection, "Description"); Keywords = GetConfigItem(ref _metaDataSection, "Keywords"); Creator = GetConfigItem(ref _metaDataSection, "Creator"); SiteTitle = GetConfigItem(ref _metaDataSection, "SiteTitle"); TopNavDisplay = GetConfigItem(ref _metaDataSection, "TopNavDisplay").Equals("true"); MenuNavDisplay = GetConfigItem(ref _metaDataSection, "MenuNavDisplay").Equals("true"); GlobalNavDisplay = GetConfigItem(ref _metaDataSection, "GlobalNavDisplay").Equals("true"); SideContentDisplay = GetConfigItem(ref _metaDataSection, "SideContentDisplay").Equals("true"); // Parse any date created string in the config var dateCreated = GetConfigItem(ref _metaDataSection, "DateCreated"); if (!string.IsNullOrEmpty(dateCreated)) { DateCreated = DateTime.Parse(dateCreated); } Menu = new MenuHelper("~/Menu.json", ConfigurationManager.AppSettings); // Find any classifications foreach (String s in _metaDataSection.AllKeys) { if (String.Compare("Classification", 0, s, 0, 14) == 0) { Classifications.Add((Classification) StringEnum.Parse(typeof (Classification), _metaDataSection[s])); } } // Set date modified as the creation date of the assembly by default if (Assembly.GetExecutingAssembly().Location != null) { try { // ReSharper disable AssignNullToNotNullAttribute DateModified = File.GetLastWriteTime(Assembly.GetExecutingAssembly().Location); // ReSharper restore AssignNullToNotNullAttribute // ReSharper disable EmptyGeneralCatchClause } catch (Exception) { } // Suppress // ReSharper restore EmptyGeneralCatchClause } }