ComponentFactory.Krypton.Toolkit.DateTimeNullableConverter.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, CultureInfo culture, object value ) : object
context ITypeDescriptorContext An ITypeDescriptorContext that provides a format context.
culture System.Globalization.CultureInfo The CultureInfo to use as the current culture.
value object The Object to convert.
return object
        public override object ConvertFrom(ITypeDescriptorContext context, 
                                           CultureInfo culture, 
                                           object value)
        {
            // We allow an empty string or a string with DBNull/null/Nothing to be converted to a DBNull value.
            if (value is string)
            {
                string stringValue = value.ToString().ToLower();
                if ((stringValue == "dbnull") || (stringValue == "null") || (stringValue == "nothing"))
                    return DBNull.Value;
            }

            return base.ConvertFrom(context, culture, value);
        }