public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
string text = value as string;
if (text != null)
{
text = text.Trim();
try
{
return TimeSpan.Parse(text, culture);
}
catch (FormatException e)
{
throw new FormatException(SR.Format(SR.ConvertInvalidPrimitive, (string)value, nameof(TimeSpan)), e);
}
}
return base.ConvertFrom(context, culture, value);
}