// Summary: // Converts the specified value object to an enumeration object. // // Parameters: // culture: // An optional System.Globalization.CultureInfo. If not supplied, the current // culture is assumed. // // context: // An System.ComponentModel.ITypeDescriptorContext that provides a format context. // // value: // The System.Object to convert. // // Returns: // An System.Object that represents the converted value. // // Exceptions: // System.NotSupportedException: // The conversion cannot be performed. // // System.FormatException: // value is not a valid value for the target type. public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { string str = value as string; if (str != null) { DynamicEnum lResult = CreateNewDynamicEnum(); lResult.EnumeratorItem = str; return(lResult); } return(base.ConvertFrom(context, culture, value)); }
// Summary: // Initializes a new instance of the System.ComponentModel.EnumConverter class // for the given type. // // Parameters: // type: // A System.Type that represents the type of enumeration to associate with this // enumeration converter. public DynamicEnumConverter(Type aType) { FDynamicEnumType = aType; FDynamicEnum = CreateNewDynamicEnum(); }