/// <summary> /// Extends ConvertTo so that methods that return a specific type object given a Type parameter can be /// used as generic method and casting is not required. /// <example> /// pointconverter.ConvertTo<int>(context, culture, value); /// </example> /// </summary> public static T ConvertTo <T>(this PointConverter pointconverter, System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, Object value) { if (pointconverter == null) { throw new ArgumentNullException("pointconverter"); } return((T)pointconverter.ConvertTo(context, culture, value, typeof(T))); }
/// <summary> /// Extends ConvertTo so that methods that return a specific type object given a Type parameter can be /// used as generic method and casting is not required. /// <example> /// typeconverter.ConvertTo<int>(value); /// </example> /// </summary> public static T ConvertTo <T>(this PointConverter typeconverter, Object value) { if (typeconverter == null) { throw new ArgumentNullException("typeconverter"); } return((T)typeconverter.ConvertTo(value, typeof(T))); }
public void ConvertTo() { PointConverter r = new PointConverter(); Point rect = new Point(1, 2); object o = r.ConvertTo(rect, typeof(string)); Assert.AreEqual(typeof(string), o.GetType()); Assert.AreEqual("1,2", (string)o); }
public void ConvertTo() { PointConverter r = new PointConverter(); Point rect = new Point(1, 2); object o = r.ConvertTo(null, CultureInfo.InvariantCulture, rect, typeof(string)); Assert.AreEqual(typeof(string), o.GetType()); Assert.AreEqual("1,2", (string)o); }
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (value is DDPoint) { Point p = (value as DDPoint).Point; return(_pointConverter.ConvertTo(context, culture, p, destinationType)); } else { return(null); } }
/// <summary> /// Convert a Point instance into a string representation. /// </summary> /// <param name="point">Point instance to be converted.</param> /// <returns>String representation of the Point instance.</returns> public static string PointToString(Point point) { return((string)_pc.ConvertTo(null, CultureInfo.InvariantCulture, point, _stringType)); }
public static string PointToString(Point point) { return((string)_pc.ConvertTo(point, _stringType)); }
public void ConvertToInvalidDestination() { new Action(() => _converter.ConvertTo(new Point(), typeof(int))).ShouldThrow <NotSupportedException>(); }