public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { return typeof(string) == destinationType || IsNumeric(destinationType) || base.CanConvertTo(context, destinationType); }
public void ConvertToInteger() { var converter = new EncodingConverter(); Assert.IsTrue(converter.CanConvertTo(typeof(int)), "Cannot convert to an integer."); var value = (int)converter.ConvertTo(Encoding.UTF8, typeof(int)); Assert.AreEqual<int>(65001, value, "Could not convert to an integer."); }