public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
if (destinationType == null)
{
throw new ArgumentNullException(nameof(destinationType));
}
if (destinationType == typeof(string))
{
return value != null ? value.ToString() : string.Empty;
}
if (value != null && destinationType == typeof(InstanceDescriptor))
{
object newValue = value;
if (value is string)
{
for (int i = 0; i < s_types.Length; i++)
{
if (s_types[i].ToString().Equals(value))
{
newValue = s_types[i];
}
}
}
if (value is Type || value is string)
{
MethodInfo method = typeof(Type).GetMethod("GetType", new Type[] { typeof(string) });
if (method != null)
{
return new InstanceDescriptor(method, new object[] { ((Type)newValue).AssemblyQualifiedName });
}
}
}
return base.ConvertTo(context, culture, value, destinationType);
}