namespace System.ComponentModel
{
[ComVisible (true)]
- public class AttributeCollection : ICollection, IEnumerable
+ public class AttributeCollection : ICollection
{
private ArrayList attrList = new ArrayList ();
public static readonly AttributeCollection Empty = new AttributeCollection ((ArrayList)null);
attrList = attributes;
}
+#if NET_2_0
+ public AttributeCollection (params Attribute[] attributes)
+#else
public AttributeCollection (Attribute[] attributes)
+#endif
{
if (attributes != null)
for (int i = 0; i < attributes.Length; i++)
attrList.Add (attributes[i]);
}
+#if NET_2_0
+ public static AttributeCollection FromExisting (AttributeCollection existing, params Attribute [] newAttributes)
+ {
+ 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
+
public bool Contains (Attribute attr)
{
- return attrList.Contains (attr);
+ Attribute at = this [attr.GetType ()];
+ if (at != null)
+ return attr.Equals (at);
+ else
+ return false;
}
public bool Contains (Attribute [] attributes)
attrList.CopyTo (array, index);
}
+ IEnumerator IEnumerable.GetEnumerator () {
+ return GetEnumerator ();
+ }
+
public IEnumerator GetEnumerator ()
{
return attrList.GetEnumerator ();
}
}
+ int ICollection.Count {
+ get {
+ return Count;
+ }
+ }
+
public int Count {
get {
return attrList.Count;
get {
Attribute attr = null;
foreach (Attribute a in attrList) {
- if (a.GetType () == type){
+ if (type.IsAssignableFrom (a.GetType ())) {
attr = a;
break;
}