Accord.Controls.RangeTypeConverter.ConvertTo C# (CSharp) Method

ConvertTo() public method

Converts the given value object to the specified type, using the specified context and culture information.
/// The parameter is null. /// /// The conversion cannot be performed. ///
public ConvertTo ( ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType ) : object
context ITypeDescriptorContext An that provides a format context.
culture System.Globalization.CultureInfo A . If null is passed, the current culture is assumed.
value object The to convert.
destinationType System.Type The to convert the parameter to.
return object
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture,
            object value, Type destinationType)
        {
            if (value is DoubleRange)
            {
                DoubleRange doubleRange = (DoubleRange)value;
                return String.Format(CultureInfo.CurrentCulture,
                    "[{0}; {1}]", doubleRange.Min, doubleRange.Max);
            }

            if (value is IntRange)
            {
                IntRange intRange = (IntRange)value;
                return String.Format(CultureInfo.CurrentCulture,
                    "[{0}; {1}]", intRange.Min, intRange.Max);
            }

            return base.ConvertTo(context, culture, value, destinationType);
        }