protected void UpdateSettingInSettingsGroup <T>(ISettingsGroup settingsGroup, string settingName, T settingValue, T defaultValue) { if (settingsGroup == null) { return; } if (settingsGroup.ContainsSetting(settingName)) { settingsGroup.GetSetting <T>(settingName).Value = settingValue; } else { if (settingValue == null) { if ((defaultValue != null)) { settingsGroup.GetSetting <T>(settingName).Value = default(T); } } else if (!settingValue.Equals(defaultValue)) { settingsGroup.GetSetting <T>(settingName).Value = settingValue; } } }
protected T GetSettingFromSettingsGroup <T>(ISettingsGroup settingsGroup, string settingName, T defaultValue) { if (settingsGroup.ContainsSetting(settingName)) { return(settingsGroup.GetSetting <T>(settingName).Value); } return(defaultValue); }
public void PopulateFromSettingsGroup(ISettingsGroup settingsGroup, string listItemSetting) { SegmentationHint = GetSettingFromSettingsGroup(settingsGroup, listItemSetting + SettingSegmentionHint, DefaultSegmentationHint); TagType = GetSettingFromSettingsGroup(settingsGroup, listItemSetting + SettingTagType, DefaultTagType); StartTagRegexValue = GetSettingFromSettingsGroup(settingsGroup, listItemSetting + SettingStartTagRegex, _defaultStartTagRegex); EndTagRegexValue = GetSettingFromSettingsGroup(settingsGroup, listItemSetting + SettingEndTagRegex, _defaultEndTagRegex); IgnoreCase = GetSettingFromSettingsGroup(settingsGroup, listItemSetting + SettingIgnoreCase, DefaultIgnoreCase); IsContentTranslatable = GetSettingFromSettingsGroup(settingsGroup, listItemSetting + SettingContentTranslatable, DefaultContentTranslatable); IsWordStop = GetSettingFromSettingsGroup(settingsGroup, listItemSetting + SettingWordStop, DefaultWordStop); IsSoftBreak = GetSettingFromSettingsGroup(settingsGroup, listItemSetting + SettingSoftBreak, DefaultSoftBreak); CanHide = GetSettingFromSettingsGroup(settingsGroup, listItemSetting + SettingCanHide, DefaultCanHide); TextEquivalent = GetSettingFromSettingsGroup(settingsGroup, listItemSetting + SettingTextEquivalent, _defaultTextEquivalent); if (settingsGroup.ContainsSetting(listItemSetting + SettingFormatting)) { _formatting = new FormattingGroupSettings(); _formatting.PopulateFromSettingsGroup(settingsGroup, listItemSetting + SettingFormatting); } }