protected string GetSetting(MethodBase mb) { ModuleSettingAttribute settingInfo = null; object setting = null; PropertyInfo propertyInfo = mb.DeclaringType.GetProperty(mb.Name.Remove(0, 4), BindingFlags.Public | BindingFlags.Instance); if (propertyInfo != null) { settingInfo = GetPropertyAttribute(propertyInfo); } if (settingInfo != null) { switch (_wrapperType) { case SettingsWrapperType.Module: setting = _controller.GetModule(_moduleID).ModuleSettings[settingInfo.Name]; break; case SettingsWrapperType.TabModule: setting = _controller.GetTabModule(_tabModuleID).TabModuleSettings[settingInfo.Name]; break; } if (setting != null && setting.ToString() != "") { return(setting.ToString()); } return(settingInfo.Default); } return(null); }
protected void SetSetting(MethodBase mb, string settingValue) { ModuleSettingAttribute settingInfo = null; string propName = mb.Name; if (propName.StartsWith("set_")) { propName = propName.Substring(4); } PropertyInfo propertyInfo = mb.DeclaringType.GetProperty(propName, BindingFlags.Public | BindingFlags.Instance); if (propertyInfo != null) { settingInfo = GetPropertyAttribute(propertyInfo); } if (settingInfo != null) { if (settingValue == null) { settingValue = string.Empty; } switch (_wrapperType) { case SettingsWrapperType.Module: _controller.UpdateModuleSetting(_moduleID, settingInfo.Name, settingValue); break; case SettingsWrapperType.TabModule: _controller.UpdateTabModuleSetting(_tabModuleID, settingInfo.Name, settingValue); break; } } }