public void ConvertFrom() { PointConverter r = new PointConverter(); object or = r.ConvertFrom("3, 4"); Assert.AreEqual(typeof(Point), or.GetType()); Assert.AreEqual(new Point(3, 4), or); or = r.ConvertFrom("-1, -4"); Assert.AreEqual(typeof(Point), or.GetType()); Assert.AreEqual(new Point(-1, -4), or); }
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value is string s) { PointConverter pc = new PointConverter(); PointSeries pl = new PointSeries(); string[] ppl = s.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); foreach (string pp in ppl) { pl.Add((Point)pc.ConvertFrom(pp)); } return(pl); } return(null); }
/// <summary> /// Convert a string representation to a Point instance. /// </summary> /// <param name="str">String representation of the Point instance.</param> /// <returns>Point instance created from string representation.</returns> public static Point StringToPoint(string str) { return((Point)_pc.ConvertFrom(null, CultureInfo.InvariantCulture, str)); }
public void ConvertFrom_size() { PointConverter r = new PointConverter(); r.ConvertFrom(new Point(10, 20)); }
public static Point StringToPoint(string str) { return((Point)_pc.ConvertFrom(str)); }
public void ConvertFromInvalidSource() { new Action(() => _converter.ConvertFrom(null)).ShouldThrow <NotSupportedException>().WithMessage("*null*"); new Action(() => _converter.ConvertFrom(new object())).ShouldThrow <NotSupportedException>().WithMessage($"*{typeof(object)}*"); }
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { Point p = (Point)_pointConverter.ConvertFrom(context, culture, value); return(new DDPoint(p)); }