public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
if (destinationType == null)
{
throw new ArgumentNullException(nameof(destinationType));
}
if (destinationType == typeof(InstanceDescriptor) && value is Decimal)
{
object[] args = new object[] { Decimal.GetBits((Decimal)value) };
MemberInfo member = typeof(Decimal).GetConstructor(new Type[] { typeof(Int32[]) });
Debug.Assert(member != null, "Could not convert decimal to member. Did someone change method name / signature and not update DecimalConverter?");
if (member != null)
{
return new InstanceDescriptor(member, args);
}
else
{
return null;
}
}
return base.ConvertTo(context, culture, value, destinationType);
}