private void InitDefaultValueFromTypeInfo(ConfigurationPropertyAttribute attribProperty,
DefaultValueAttribute attribStdDefault) {
object defaultValue = attribProperty.DefaultValue;
// If there is no default value there - try the other attribute ( the clr standard one )
if ((defaultValue == null || defaultValue == ConfigurationElement.s_nullPropertyValue) &&
(attribStdDefault != null)) {
defaultValue = attribStdDefault.Value;
}
// If there was a default value in the prop attribute - check if we need to convert it from string
if ((defaultValue != null) && (defaultValue is string) && (_type != typeof(string))) {
// Use the converter to parse this property default value
try {
defaultValue = Converter.ConvertFromInvariantString((string)defaultValue);
}
catch (Exception ex) {
throw new ConfigurationErrorsException(SR.GetString(SR.Default_value_conversion_error_from_string, _name, ex.Message));
}
catch {
throw new ConfigurationErrorsException(SR.GetString(SR.Default_value_conversion_error_from_string, _name, ExceptionUtil.NoExceptionInformation));
}
}
if (defaultValue == null || defaultValue == ConfigurationElement.s_nullPropertyValue) {
if (_type == typeof(string)) {
defaultValue = String.Empty;
}
else if (_type.IsValueType) {
defaultValue = TypeUtil.CreateInstanceWithReflectionPermission(_type);
}
}
SetDefaultValue(defaultValue);
}