private object GetSettingValueFromConfigValue(PluginSettingAttribute attribute, Type propertyType, string value) { //TODO: add some kind of validation and error handling for bad config values /* * switch(attribute.Type) * { * case PluginSettingType.Text: * case PluginSettingType.MaskedText: * case PluginSettingType.PasswordText: * case PluginSettingType.DirectoryPath: * case PluginSettingType.FileName: * case PluginSettingType.FilePath: * return value; * case PluginSettingType.Boolean: * return Convert.ToBoolean(value); * case PluginSettingType.Integer: * if (propertyType == typeof(short)) * return Convert.ToInt16(value); * else if (propertyType == typeof(ushort)) * return Convert.ToUInt16(value); * else if (propertyType == typeof(int)) * return Convert.ToInt32(value); * else if (propertyType == typeof(uint)) * return Convert.ToUInt32(value); * else if (propertyType == typeof(long)) * return Convert.ToInt64(value); * else if (propertyType == typeof(ulong)) * return Convert.ToUInt64(value); * else if (propertyType == typeof(decimal)) * return Convert.ToDecimal(value); * else throw new AlexandriaException("Could not convert configuration integer value"); * case PluginSettingType.Real: * if (propertyType == typeof(float)) * return Convert.ToSingle(value); * else if (propertyType == typeof(double)) * return Convert.ToDouble(value); * else if (propertyType == typeof(decimal)) * return Convert.ToDecimal(value); * else throw new AlexandriaException("Could not convert configuration real value"); * case PluginSettingType.Enumeration: * return Enum.Parse(propertyType, value); * default: * return null; * } */ return(null); }
private object GetSettingValueFromConfigValue(PluginSettingAttribute attribute, Type propertyType, string value) { //TODO: add some kind of validation and error handling for bad config values /* switch(attribute.Type) { case PluginSettingType.Text: case PluginSettingType.MaskedText: case PluginSettingType.PasswordText: case PluginSettingType.DirectoryPath: case PluginSettingType.FileName: case PluginSettingType.FilePath: return value; case PluginSettingType.Boolean: return Convert.ToBoolean(value); case PluginSettingType.Integer: if (propertyType == typeof(short)) return Convert.ToInt16(value); else if (propertyType == typeof(ushort)) return Convert.ToUInt16(value); else if (propertyType == typeof(int)) return Convert.ToInt32(value); else if (propertyType == typeof(uint)) return Convert.ToUInt32(value); else if (propertyType == typeof(long)) return Convert.ToInt64(value); else if (propertyType == typeof(ulong)) return Convert.ToUInt64(value); else if (propertyType == typeof(decimal)) return Convert.ToDecimal(value); else throw new AlexandriaException("Could not convert configuration integer value"); case PluginSettingType.Real: if (propertyType == typeof(float)) return Convert.ToSingle(value); else if (propertyType == typeof(double)) return Convert.ToDouble(value); else if (propertyType == typeof(decimal)) return Convert.ToDecimal(value); else throw new AlexandriaException("Could not convert configuration real value"); case PluginSettingType.Enumeration: return Enum.Parse(propertyType, value); default: return null; } */ return null; }