protected override bool SetValueInternal(object value, ValueUpdateSource updateSource) { bool result; // Update the new value of this property if (value is string) { if (UnderlyingType.IsEnum) { object enumValue = TypeConverter.ConvertFromString(GetTypeDescriptorContext(OwnerEnumerator), CultureInfo, GetActualString(value as string)); // If the enum is flagged, we don't test if the value to be assigned is correct if (UnderlyingType.IsDefined(typeof(FlagsAttribute), false)) { result = SetMultipleValues(enumValue); } else { if (Enum.IsDefined(UnderlyingType, enumValue)) { result = SetMultipleValues(enumValue); } else { result = false; } } } else { PropertyTypeDescriptorContext context = GetTypeDescriptorContext(OwnerEnumerator); string str = GetActualString(value as string); if (TypeConverter.CanConvertFrom(context, typeof(string))) { result = SetMultipleValues(TypeConverter.ConvertFromString( context, CultureInfo, str)); } else { result = SetMultipleValues(str); } } } else { result = SetMultipleValues(value); } return(result); }
bool ICustomAttributeProvider.IsDefined(Type attributeType, bool inherit) { return(UnderlyingType.IsDefined(attributeType, inherit)); }