New test.
[mono.git] / mcs / class / System.Drawing / System.Drawing / RectangleConverter.cs
index d7fffbe6e3d47030fdc07c50c7dd8f4cbdf145fa..b9c96e5a96e3c16c85a790475f58a5b81207fe38 100644 (file)
@@ -7,11 +7,7 @@
 //     Ravindra (rkumar@novell.com)
 //     
 // Copyright (C) 2002 Ximian, Inc. http://www.ximian.com
-// Copyright (C) 2004 Novell, Inc. http://www.novell.com
-//
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2004, 2006 Novell, Inc (http://www.novell.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -33,7 +29,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-using System;
 using System.ComponentModel;
 using System.Collections;
 using System.Globalization;
@@ -41,11 +36,8 @@ using System.Text;
 using System.ComponentModel.Design.Serialization;
 using System.Reflection;
 
-namespace System.Drawing
-{
-       /// <summary>
-       /// Summary description for RectangleConverter.
-       /// </summary>
+namespace System.Drawing {
+
        public class RectangleConverter : TypeConverter
        {
                public RectangleConverter ()
@@ -133,11 +125,24 @@ namespace System.Drawing
                public override object CreateInstance (ITypeDescriptorContext context,
                                                       IDictionary propertyValues)
                {
+#if NET_2_0
+                       object ox = propertyValues ["X"];
+                       object oy = propertyValues ["Y"];
+                       object ow = propertyValues ["Width"];
+                       object oh = propertyValues ["Height"];
+                       if ((ox == null) || (oy == null) || (ow == null) || (oh == null))
+                               throw new ArgumentException ("propertyValues");
+
+                       int x = (int) ox;
+                       int y = (int) oy;
+                       int width = (int) ow;
+                       int height = (int) oh;
+#else
                        int x = (int) propertyValues ["X"];
                        int y = (int) propertyValues ["Y"];
                        int width = (int) propertyValues ["Width"];
                        int height = (int) propertyValues ["Height"];
-
+#endif
                        return new Rectangle (x, y, width, height);
                }