2007-10-29 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Mon, 29 Oct 2007 15:30:55 +0000 (15:30 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Mon, 29 Oct 2007 15:30:55 +0000 (15:30 -0000)
* AttributeCollection.cs : implemented FromExisting().
* Container.cs : implemented ValidateName() support.
* ContainerFilterService.cs : FilterComponents() does nothing.
* InstanceCreationEditor.cs : implemented get_Text().

* ContainerTest.cs : added test for ValidateName().

svn path=/trunk/mcs/; revision=88388

mcs/class/System/System.ComponentModel/AttributeCollection.cs
mcs/class/System/System.ComponentModel/ChangeLog
mcs/class/System/System.ComponentModel/Container.cs
mcs/class/System/System.ComponentModel/ContainerFilterService.cs
mcs/class/System/System.ComponentModel/InstanceCreationEditor.cs
mcs/class/System/Test/System.ComponentModel/ChangeLog
mcs/class/System/Test/System.ComponentModel/ContainerTest.cs

index 55bbf32978497d693c94a4985a3ea0b3c0b4590f..8e11797c9eb8d8d8810b006d6851727ecb7574bb 100644 (file)
@@ -59,10 +59,15 @@ namespace System.ComponentModel
                }
 
 #if NET_2_0
-               [MonoNotSupported("")]
                public static AttributeCollection FromExisting (AttributeCollection existing, params Attribute [] newAttributes)
                {
-                       throw new NotImplementedException ();
+                       if (existing == null)
+                               throw new ArgumentNullException ("existing");
+                       AttributeCollection ret = new AttributeCollection ();
+                       ret.attrList.AddRange (existing.attrList);
+                       if (newAttributes != null)
+                               ret.attrList.AddRange (newAttributes);
+                       return ret;
                }
 #endif
 
index cafb41da5db0c4c1acb94a7e6ac6ff17962abc30..abd3c0bf3c86619920020eda03510c8edc23a9a4 100644 (file)
@@ -1,3 +1,10 @@
+2007-10-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AttributeCollection.cs : implemented FromExisting().
+       * Container.cs : implemented ValidateName() support.
+       * ContainerFilterService.cs : FilterComponents() does nothing.
+       * InstanceCreationEditor.cs : implemented get_Text().
+
 2007-09-27  Atsushi Enomoto  <atsushi@ximian.com>
 
        * TypeDescriptor.cs : added missing ObsoleteAttribute.
index 9839663e880387329324fc97a79996b4f06818d0..28168ef2fe725f87fcaaf825adb939cb2443b5d5 100644 (file)
@@ -135,7 +135,9 @@ namespace System.ComponentModel {
                                        if (component.Site != null) {
                                                component.Site.Container.Remove (component);
                                        }
-                                       
+#if NET_2_0
+                                       ValidateName (component, name);
+#endif
                                        component.Site = this.CreateSite (component, name);
                                        c.Add (component);
                                }
@@ -143,10 +145,15 @@ namespace System.ComponentModel {
                }
 
 #if NET_2_0
-               [MonoNotSupported("")]
                protected virtual void ValidateName (IComponent component, string name)
                {
-                       throw new NotImplementedException ();
+                       if (component == null)
+                               throw new ArgumentNullException ("component");
+                       if (name == null)
+                               return;
+                       foreach (IComponent ic in c)
+                               if (ic.Site != null && ic.Site.Name == name)
+                                       throw new ArgumentException (String.Format ("There already is a named component '{0}' in this container", name));
                }
 #endif
 
index 95c036c4b3c28d912742bb677d9e6cd4b3c9f371..bc6fa39478173af297ce88a0e6f507a255c98595 100644 (file)
@@ -36,10 +36,10 @@ namespace System.ComponentModel
 {
        public abstract class ContainerFilterService
        {
-               [MonoTODO]
                public virtual ComponentCollection FilterComponents (ComponentCollection components)
                {
-                       throw new NotImplementedException ();
+                       // The default implementation returns the input as is.
+                       return components;
                }
        }
 }
index 9ff3b476d710bcd59270a1aee751a40b43ce5adb..ee8aab923350fda57b6c05e3c223342b181771ca 100644 (file)
@@ -36,9 +36,8 @@ namespace System.ComponentModel
 {
        public abstract class InstanceCreationEditor
        {
-               [MonoTODO]
                public virtual string Text {
-                       get { throw new NotImplementedException (); }
+                       get { return Locale.GetText ("(New ...)"); }
                }
 
                public abstract object CreateInstance (ITypeDescriptorContext context, Type type);
index ec10bafb1c2547943b225e36b18b9f640cdcd4f5..a4e57c0222a7e245826345a74e3901d432738c8f 100644 (file)
@@ -1,3 +1,7 @@
+2007-10-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ContainerTest.cs : added test for ValidateName().
+
 2007-09-28  Jb Evain  <jbevain@novell.com>
 
        * TypeConverterTests.cs: test case for bug #329450.
index 7821ba85c03ca22c7d4538dafaa2bb671c2c571d..78e0f1533202f19fd387ffec94ae10cafe3be028 100644 (file)
@@ -105,5 +105,18 @@ namespace MonoTests.System.ComponentModel
                {
                        _container.Add (new TestComponent ());
                }
+
+#if NET_2_0
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void ValidateName ()
+               {
+                       TestContainer container = new TestContainer ();
+                       TestComponent c1 = new TestComponent ();
+                       container.Add (c1, "dup");
+                       TestComponent c2 = new TestComponent ();
+                       container.Add (c2, "dup");
+               }
+#endif
        }
 }