Author: jordi
Date: 2005-06-29 06:36:46 -0400 (Wed, 29 Jun 2005)
New Revision: 46712

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ControlBindingsCollection.cs
Log:
2005-06-29  Jordi Mas i Hernandez <[EMAIL PROTECTED]>
        
        * ControlBindingsCollection.cs
                - Throws an exception on null datasource when adding
                - Checks for duplicated bindings when adding



Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2005-06-29 10:29:56 UTC (rev 46711)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2005-06-29 10:36:46 UTC (rev 46712)
@@ -1,3 +1,9 @@
+2005-06-29  Jordi Mas i Hernandez <[EMAIL PROTECTED]>
+       
+       * ControlBindingsCollection.cs
+               - Throws an exception on null datasource when adding
+               - Checks for duplicated bindings when adding
+
 2005-06-28  Jackson Harper  <[EMAIL PROTECTED]>
 
        * TreeView.cs (OnKeyDown): Support left and right properly

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ControlBindingsCollection.cs
===================================================================
--- 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ControlBindingsCollection.cs
     2005-06-29 10:29:56 UTC (rev 46711)
+++ 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ControlBindingsCollection.cs
     2005-06-29 10:36:46 UTC (rev 46712)
@@ -72,6 +72,10 @@
 
                public Binding Add (string property_name, object data_source, 
string data_member)
                {
+                       if (data_source == null) {
+                               throw new ArgumentNullException ("DataSource 
cannot be null.");
+                       }                       
+                       
                        Binding res = new Binding (property_name, data_source, 
data_member);
                        Add (res);
                        return res;
@@ -106,7 +110,18 @@
 
                        if (binding.Control != null && binding.Control != 
control)
                                  throw new ArgumentException ("dataBinding 
belongs to another BindingsCollection");
+                                 
+                       for (int i = 0; i < Count; i++) {
+                               Binding bnd = this [i];
+                               if (bnd == null || bnd.PropertyName.Length == 0 
|| binding.PropertyName.Length == 0) {
+                                       continue;
+                               }
 
+                               if (String.Compare (bnd.PropertyName, 
binding.PropertyName, true) == 0) {
+                                       throw new ArgumentException ("The 
binding is already in the collection");
+                               }
+                       }
+
                        binding.SetControl (control);
                        base.AddCore (binding);
                }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to