public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
if (value == null)
return base.ConvertFrom(context, culture, value);
String str = value as String;
if (str == null)
return base.ConvertFrom(context, culture, value);
str = str.Replace("(", String.Empty);
str = str.Replace(")", String.Empty);
str = str.Replace("[", String.Empty);
str = str.Replace("]", String.Empty);
String[] parts = str.Split(';');
string a = parts[0];
string b = parts[1];
if (context.PropertyDescriptor.PropertyType == typeof(IntRange))
{
int max = int.Parse(a);
int min = int.Parse(b);
return new IntRange(min, max);
}
else if (context.PropertyDescriptor.PropertyType == typeof(DoubleRange))
{
double max = double.Parse(a);
double min = double.Parse(b);
return new DoubleRange(min, max);
}
return base.ConvertFrom(context, culture, value);
}