System.ComponentModel.TypeConverter.ConvertFrom C# (CSharp) Method

ConvertFrom() public method

public ConvertFrom ( ITypeDescriptorContext context, CultureInfo culture, object value ) : object
context ITypeDescriptorContext
culture System.Globalization.CultureInfo
value object
return object
        public virtual object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) {
            InstanceDescriptor id = value as InstanceDescriptor;
            if (id != null) {
                return id.Invoke();
            }
            throw GetConvertFromException(value);
        }

Same methods

TypeConverter::ConvertFrom ( object value ) : object

Usage Example

        /// <inheritdoc />
        public override bool TryConvert(object value, Type destinationType, out object result, ConversionArgs args)
        {
            System.ComponentModel.TypeConverter converter = TypeDescriptor.GetConverter(destinationType);
            if (converter.GetType() != typeof(System.ComponentModel.TypeConverter) && converter.CanConvertFrom(value.GetType()))
            {
                try {
                    result = converter.ConvertFrom(null, args.Culture, value);
                    return(true);
                }
                catch {
                }
            }

            converter = TypeDescriptor.GetConverter(value.GetType());
            if (converter.GetType() != typeof(System.ComponentModel.TypeConverter) && converter.CanConvertTo(destinationType))
            {
                try {
                    result = converter.ConvertTo(null, args.Culture, value, destinationType);
                    return(true);
                }
                catch {
                }
            }

            result = null;
            return(false);
        }
All Usage Examples Of System.ComponentModel.TypeConverter::ConvertFrom