mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-17 19:10:23 -10:00
* DesignerAttribute.cs: Fixed property TypeId. * EventDescriptorCollection.cs: Added internal constructor. Added new method Filter that removes events that do not have the specified attributes. * MemberDescriptor.cs: Minor fixes. * PropertyDescriptor.cs: Implemented some missing methods. * PropertyDescriptorCollection.cs: Added internal constructor. Implemented Sort methods. * ReferenceConverter.cs: Removed some TODOs. * SyntaxCheck.cs: Implemented CheckMachineName and CheckPath. * TypeDescriptor.cs: Implemented most of missing methods. svn path=/trunk/mcs/; revision=25473
140 lines
2.7 KiB
C#
140 lines
2.7 KiB
C#
//
|
|
// System.ComponentModel.AttributeCollection.cs
|
|
//
|
|
// Authors:
|
|
// Rodrigo Moya ([email protected])
|
|
// Gonzalo Paniagua Javier ([email protected])
|
|
//
|
|
// (C) 2002 Ximian, Inc. (http://www.ximian.com)
|
|
//
|
|
|
|
using System;
|
|
using System.Collections;
|
|
using System.Reflection;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace System.ComponentModel
|
|
{
|
|
[ComVisible (true)]
|
|
public class AttributeCollection : ICollection, IEnumerable
|
|
{
|
|
private ArrayList attrList = new ArrayList ();
|
|
public static readonly AttributeCollection Empty = new AttributeCollection ((ArrayList)null);
|
|
|
|
internal AttributeCollection (ArrayList attributes)
|
|
{
|
|
attrList = attributes;
|
|
}
|
|
|
|
public AttributeCollection (Attribute[] attributes)
|
|
{
|
|
if (attributes != null)
|
|
for (int i = 0; i < attributes.Length; i++)
|
|
attrList.Add (attributes[i]);
|
|
}
|
|
|
|
public bool Contains (Attribute attr)
|
|
{
|
|
return attrList.Contains (attr);
|
|
}
|
|
|
|
public bool Contains (Attribute [] attributes)
|
|
{
|
|
if (attributes == null)
|
|
return true;
|
|
|
|
foreach (Attribute attr in attributes)
|
|
if (!Contains (attr))
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
public void CopyTo (Array array, int index)
|
|
{
|
|
attrList.CopyTo (array, index);
|
|
}
|
|
|
|
public IEnumerator GetEnumerator ()
|
|
{
|
|
return attrList.GetEnumerator ();
|
|
}
|
|
|
|
public bool Matches (Attribute attr)
|
|
{
|
|
foreach (Attribute a in attrList)
|
|
if (a.Match (attr))
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
public bool Matches (Attribute [] attributes)
|
|
{
|
|
foreach (Attribute a in attributes)
|
|
if (!(Matches (a)))
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
protected Attribute GetDefaultAttribute (Type attributeType)
|
|
{
|
|
Attribute attr = null;
|
|
BindingFlags bf = BindingFlags.Public | BindingFlags.Static;
|
|
|
|
FieldInfo def = attributeType.GetField ("Default", bf);
|
|
if (def == null) {
|
|
ConstructorInfo constructorInfo = attributeType.GetConstructor (Type.EmptyTypes);
|
|
if (constructorInfo != null)
|
|
attr = constructorInfo.Invoke (null) as Attribute;
|
|
if (attr != null && !attr.IsDefaultAttribute ())
|
|
attr = null;
|
|
} else {
|
|
attr = (Attribute) def.GetValue (null);
|
|
}
|
|
|
|
return attr;
|
|
}
|
|
|
|
bool ICollection.IsSynchronized {
|
|
get {
|
|
return attrList.IsSynchronized;
|
|
}
|
|
}
|
|
|
|
object ICollection.SyncRoot {
|
|
get {
|
|
return attrList.SyncRoot;
|
|
}
|
|
}
|
|
|
|
public int Count {
|
|
get {
|
|
return attrList.Count;
|
|
}
|
|
}
|
|
|
|
public virtual Attribute this[Type type] {
|
|
get {
|
|
Attribute attr = null;
|
|
foreach (Attribute a in attrList) {
|
|
if (a.GetType () == type){
|
|
attr = a;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (attr == null)
|
|
attr = GetDefaultAttribute (type);
|
|
|
|
return attr;
|
|
}
|
|
}
|
|
|
|
public virtual Attribute this[int index] {
|
|
get {
|
|
return (Attribute) attrList [index];
|
|
}
|
|
}
|
|
}
|
|
}
|