/// <summary> /// Get localized template settings /// </summary> /// <returns></returns> public static TemplateSettingBox GetTemplateSettingsBox() { var settingsBox = new TemplateSettingBox() { Settings = new List<TemplateSetting>() }; string templateConfigFile = SettingsGeneral.AbsolutePath + (SettingsDesign.Template != TemplateService.DefaultTemplateId ? ("templates\\" + SettingsDesign.Template + "\\") : "App_Data\\") + TemplateFileConfigName; if (!File.Exists(templateConfigFile)) { settingsBox.Message = Resource.Admin_TemplateSettings_ConfigNotExist; return settingsBox; } try { var settings = settingsBox.Settings; var resourceManager = new ResourceManager(typeof(Resource)); var doc = XDocument.Load(templateConfigFile); foreach (var elSection in doc.Root.Elements()) { string sectionName = resourceManager.GetString("Admin_TemplateSettings_" + elSection.Attribute("Title").Value).Default(elSection.Attribute("Title").Value); if (elSection.Attribute("Hidden") != null && Convert.ToBoolean(elSection.Attribute("Hidden").Value)) continue; foreach (var elSetting in elSection.Elements()) { var setting = new TemplateSetting { Name = elSetting.Attribute("Name").Value, Type = elSetting.Attribute("Type").Value, Value = elSetting.Element("Value").Value, SectionName = sectionName }; setting.Title = elSetting.Attribute("Title") != null ? resourceManager.GetString("Admin_TemplateSettings_" + elSetting.Attribute("Title").Value).Default(elSetting.Attribute("Title").Value) : resourceManager.GetString("Admin_TemplateSettings_" + setting.Name).Default(setting.Name); var options = new List<TemplateOptionSetting>(); foreach (var elOption in elSetting.Elements("option")) { string title = elOption.Attribute("Title").Value; options.Add(new TemplateOptionSetting { Title = resourceManager.GetString("Admin_TemplateSettings_" + title).Default(title), Value = elOption.Attribute("Value").Value }); } setting.Options = options; settings.Add(setting); } } } catch (Exception ex) { settingsBox.Message = Resource.Admin_TemplateSettings_ErrorReadConfig; Debug.LogError(ex); } return settingsBox; }
/// <summary> /// Get localized template settings /// </summary> /// <returns></returns> public static TemplateSettingBox GetTemplateSettingsBox() { var settingsBox = new TemplateSettingBox() { Settings = new List <TemplateSetting>() }; string templateConfigFile = SettingsGeneral.AbsolutePath + (SettingsDesign.Template != TemplateService.DefaultTemplateId ? ("templates\\" + SettingsDesign.Template + "\\") : "App_Data\\") + TemplateFileConfigName; if (!File.Exists(templateConfigFile)) { settingsBox.Message = Resource.Admin_TemplateSettings_ConfigNotExist; return(settingsBox); } try { var settings = settingsBox.Settings; var resourceManager = new ResourceManager(typeof(Resource)); var doc = XDocument.Load(templateConfigFile); foreach (var elSection in doc.Root.Elements()) { string sectionName = resourceManager.GetString("Admin_TemplateSettings_" + elSection.Attribute("Title").Value).Default(elSection.Attribute("Title").Value); if (elSection.Attribute("Hidden") != null && Convert.ToBoolean(elSection.Attribute("Hidden").Value)) { continue; } foreach (var elSetting in elSection.Elements()) { var setting = new TemplateSetting { Name = elSetting.Attribute("Name").Value, Type = elSetting.Attribute("Type").Value, Value = elSetting.Element("Value").Value, SectionName = sectionName }; setting.Title = elSetting.Attribute("Title") != null ? resourceManager.GetString("Admin_TemplateSettings_" + elSetting.Attribute("Title").Value).Default(elSetting.Attribute("Title").Value) : resourceManager.GetString("Admin_TemplateSettings_" + setting.Name).Default(setting.Name); var options = new List <TemplateOptionSetting>(); foreach (var elOption in elSetting.Elements("option")) { string title = elOption.Attribute("Title").Value; options.Add(new TemplateOptionSetting { Title = resourceManager.GetString("Admin_TemplateSettings_" + title).Default(title), Value = elOption.Attribute("Value").Value }); } setting.Options = options; settings.Add(setting); } } } catch (Exception ex) { settingsBox.Message = Resource.Admin_TemplateSettings_ErrorReadConfig; Debug.LogError(ex); } return(settingsBox); }