public override object GetObjectValue(string sectionName, string keyName) { IConfigKeyValuePair keyValue = _storeValues[sectionName][keyName]; object result = null; if (keyValue != null) { if (keyValue is ConfigKeyValuePairLong) { result = RegistryHelper.GetValueInt64(null, sectionName, keyName, 0); } else if (keyValue is ConfigKeyValuePairInt) { result = RegistryHelper.GetValueInt32(null, sectionName, keyName, 0); } else if (keyValue is ConfigKeyValuePairBool) { result = RegistryHelper.GetValueBool(null, sectionName, keyName, false); } else { result = RegistryHelper.GetValueString(null, sectionName, keyName, string.Empty); } } return(result); }
public override T GetValue <T>(string sectionName, string keyName, T defaultValue) { IConfigKeyValuePair keyValue = _storeValues[sectionName][keyName]; object result = null; object resultT = defaultValue; object defaultValue2 = Convert.ChangeType(defaultValue, typeof(T)); Type typeOfT = typeof(T); if (keyValue != null) { if (typeOfT == typeof(long)) { resultT = RegistryHelper.GetValueInt64(null, sectionName, keyName, ((int)defaultValue2)); } else if (typeOfT == typeof(int)) { resultT = RegistryHelper.GetValueInt32(null, sectionName, keyName, ((int)defaultValue2)); } else if (typeOfT == typeof(bool)) { resultT = RegistryHelper.GetValueBool(null, sectionName, keyName, ((bool)defaultValue2)); } else { resultT = RegistryHelper.GetValueString(null, sectionName, keyName, ((string)defaultValue2)); } } if (typeof(T) == typeof(string)) { if (resultT != null) { result = resultT.ToString(); } return((T)result); } else { return((T)resultT); } }