2010-01-09 Marek Habersack <mhabersack@novell.com>
[mono.git] / mcs / class / System.Configuration / System.Configuration / ConfigurationElementCollection.cs
index 014dea4a5a6ce0f717db8be31c14518607c60ed9..db98f4c4067d25ffe4617febe9cbdcfd4d3c0504 100644 (file)
@@ -66,8 +66,10 @@ namespace System.Configuration
                internal override void InitFromProperty (PropertyInformation propertyInfo)
                {
                        ConfigurationCollectionAttribute colat = propertyInfo.Property.CollectionAttribute;
+       
                        if (colat == null)
-                               colat = ElementMap.GetMap (GetType ()).CollectionAttribute;
+                               colat = Attribute.GetCustomAttribute (propertyInfo.Type, typeof (ConfigurationCollectionAttribute)) as ConfigurationCollectionAttribute;
+
                        if (colat != null) {
                                addElementName = colat.AddItemName;
                                clearElementName = colat.ClearItemsName;
@@ -120,7 +122,13 @@ namespace System.Configuration
                }
 
                protected virtual bool ThrowOnDuplicate {
-                       get { return true; }
+                       get {
+                               if (CollectionType != ConfigurationElementCollectionType.AddRemoveClearMap &&
+                                   CollectionType != ConfigurationElementCollectionType.AddRemoveClearMapAlternate)
+                                       return false;
+                               
+                               return true;
+                       }
                }
                
                protected internal string AddElementName {