public void CanConvertFrom () { Int32RectConverter r = new Int32RectConverter (); Assert.IsTrue (r.CanConvertFrom (typeof (string))); Assert.IsFalse (r.CanConvertFrom (typeof (Int32Rect))); Assert.IsFalse (r.CanConvertFrom (typeof (Size))); }
private static Int32Rect Int32RectFromRect(Rect inputRect) { Int32RectConverter converter = new Int32RectConverter(); if (converter.CanConvertFrom(inputRect.GetType())) return (Int32Rect)converter.ConvertFrom(inputRect); Int32Rect outRect = new Int32Rect((int)inputRect.X, (int)inputRect.Y, (int)inputRect.Width, (int)inputRect.Height); return outRect; }