[WindowsBase] Fix exception type in *ValueSerializer.ConvertFromString with null...
[mono.git] / mcs / class / WindowsBase / System.Windows.Converters / Int32RectValueSerializer.cs
index a6681780275aaf59355fe2336cfd717b03fc97b9..acaa7b2852a9a32556a45e55886f5e1a426795c3 100644 (file)
@@ -23,7 +23,7 @@
 //     Chris Toshok (toshok@ximian.com)
 //
 
-using System;
+using System.Globalization;
 using System.Windows.Markup;
 
 namespace System.Windows.Converters {
@@ -32,22 +32,26 @@ namespace System.Windows.Converters {
        {
                public override bool CanConvertFromString (string value, IValueSerializerContext context)
                {
-                       throw new NotImplementedException ();
+                       return true;
                }
 
                public override bool CanConvertToString (object value, IValueSerializerContext context)
                {
-                       throw new NotImplementedException ();
+                       return value is Int32Rect;
                }
 
                public override object ConvertFromString (string value, IValueSerializerContext context)
                {
-                       throw new NotImplementedException ();
+                       if (value == null)
+                               throw new NotSupportedException ("value != null");
+                       return Int32Rect.Parse (value);
                }
 
                public override string ConvertToString (object value, IValueSerializerContext context)
                {
-                       throw new NotImplementedException ();
+                       if (value is Int32Rect int32Rect)
+                               return int32Rect.ToString (CultureInfo.InvariantCulture);
+                       return base.ConvertToString (value, context);
                }
        }