ComponentFactory.Krypton.Toolkit.StringLookupConverter.ConvertFrom C# (CSharp) Method

ConvertFrom() public method

Converts the given object to the type of this converter, using the specified context and culture information.
public ConvertFrom ( ITypeDescriptorContext context, System culture, object value ) : object
context ITypeDescriptorContext An ITypeDescriptorContext that provides a format context.
culture System The CultureInfo to use as the current culture.
value object The Object to convert.
return object
        public override object ConvertFrom(ITypeDescriptorContext context, 
                                           System.Globalization.CultureInfo culture, 
                                           object value)
        {
            // We are only interested in adding functionality for converting from strings
            if (value is string)
            {
                // Search for a matching string
                foreach (Pair p in Pairs)
                    if (p.Display.Equals(value))
                        return p.Enum;
            }

            // Let base class perform default conversion
            return base.ConvertFrom(context, culture, value);
        }