public override object ConvertTo(
ITypeDescriptorContext context,
System.Globalization.CultureInfo culture,
object value,
Type destinationType)
{
if ((value != null) && (!(value is SortExpression)))
{
string msg = $"Unable to convert type '{value.GetType()}'!";
throw new Exception(msg);
}
if (destinationType == typeof (string))
{
if (value == null)
{
return String.Empty;
}
SortExpression sort = value as SortExpression;
string data = String.Format(
"{1}{0}{2}{0}{3}",
SortExpressionFieldDelimiter, sort.Title, sort.Expression,
sort.Direction);
return data;
}
return base.ConvertTo(context, culture, value, destinationType);
}