10 [HostProtection(
SecurityAction.LinkDemand, Synchronization =
true)]
13 private struct AttributeEntry
23 private static Hashtable _defaultAttributes;
27 private static object internalSyncObject =
new object();
29 private const int FOUND_TYPES_LIMIT = 5;
31 private AttributeEntry[] _foundAttributeTypes;
61 lock (internalSyncObject)
63 if (_foundAttributeTypes ==
null)
65 _foundAttributeTypes =
new AttributeEntry[5];
68 for (i = 0; i < 5; i++)
70 if (_foundAttributeTypes[i].type == attributeType)
72 int index = _foundAttributeTypes[i].index;
79 if (_foundAttributeTypes[i].type ==
null)
89 _foundAttributeTypes[i].type = attributeType;
91 for (
int j = 0; j < num; j++)
94 Type type = attribute.GetType();
95 if (type == attributeType)
97 _foundAttributeTypes[i].index = j;
101 for (
int k = 0; k < num; k++)
104 Type type2 = attribute2.GetType();
105 if (attributeType.IsAssignableFrom(type2))
107 _foundAttributeTypes[i].index = k;
111 _foundAttributeTypes[i].index = -1;
154 if (attributes ==
null)
158 _attributes = attributes;
162 if (num < attributes.Length)
164 if (attributes[num] ==
null)
189 if (existing ==
null)
193 if (newAttributes ==
null)
198 int num = existing.
Count;
199 existing.
CopyTo(array, 0);
200 for (
int i = 0; i < newAttributes.Length; i++)
202 if (newAttributes[i] ==
null)
207 for (
int j = 0; j < existing.
Count; j++)
209 if (array[j].TypeId.Equals(newAttributes[i].TypeId))
212 array[j] = newAttributes[i];
218 array[num++] = newAttributes[i];
222 if (num < array.Length)
240 Attribute attribute2 =
this[attribute.GetType()];
241 if (attribute2 !=
null && attribute2.
Equals(attribute))
254 if (attributes ==
null)
258 for (
int i = 0; i < attributes.Length; i++)
273 lock (internalSyncObject)
275 if (_defaultAttributes ==
null)
281 return (
Attribute)_defaultAttributes[attributeType];
286 if (field !=
null && field.
IsStatic)
293 if (constructor !=
null)
302 _defaultAttributes[attributeType] = attribute;
336 for (
int i = 0; i < attributes.Length; i++)
abstract FieldInfo GetField(string name, BindingFlags bindingAttr)
Searches for the specified field, using the specified binding constraints.
int Count
Gets the number of attributes.
object SyncRoot
Gets an object that can be used to synchronize access to the T:System.Collections....
static readonly AttributeCollection Empty
Specifies an empty collection that you can use, rather than creating a new one. This field is read-on...
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
bool IsStatic
Gets a value indicating whether the field is static.
bool Matches(Attribute attribute)
Determines whether a specified attribute is the same as an attribute in the collection.
Discovers the attributes of a class constructor and provides access to constructor metadata.
Represents the base class for custom attributes.
Discovers the attributes of a field and provides access to field metadata.
BindingFlags
Specifies flags that control binding and the way in which the search for members and types is conduct...
abstract Type UnderlyingSystemType
Indicates the type provided by the common language runtime that represents this type.
ConstructorInfo GetConstructor(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
Searches for a constructor whose parameters match the specified argument types and modifiers,...
abstract object GetValue(object obj)
When overridden in a derived class, returns the value of a field supported by a given object.
bool Contains(Attribute attribute)
Determines whether this collection of attributes has the specified attribute.
virtual bool ContainsKey(object key)
Determines whether the T:System.Collections.Hashtable contains a specific key.
Exposes an enumerator, which supports a simple iteration over a non-generic collection....
SecurityAction
Specifies the security actions that can be performed using declarative security.
Attribute GetDefaultAttribute(Type attributeType)
Returns the default T:System.Attribute of a given T:System.Type.
AttributeCollection(params Attribute[] attributes)
Initializes a new instance of the T:System.ComponentModel.AttributeCollection class.
Represents a collection of key/value pairs that are organized based on the hash code of the key....
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
bool IsSynchronized
Gets a value indicating whether access to the T:System.Collections.ICollection is synchronized (threa...
Represents type declarations: class types, interface types, array types, value types,...
Provides information about the characteristics for a component, such as its attributes,...
bool Contains(Attribute[] attributes)
Determines whether this attribute collection contains all the specified attributes in the attribute a...
IEnumerator GetEnumerator()
Gets an enumerator for this collection.
AttributeCollection()
Initializes a new instance of the T:System.ComponentModel.AttributeCollection class.
IEnumerator GetEnumerator()
Returns an enumerator that iterates through a collection.
Represents a collection of attributes.
void CopyTo(Array array, int index)
Copies the collection to an array, starting at the specified index.
static void Copy(Array sourceArray, Array destinationArray, int length)
Copies a range of elements from an T:System.Array starting at the first element and pastes them into ...
static Type GetReflectionType(Type type)
Returns a T:System.Type that can be used to perform reflection, given a class type.
abstract object Invoke(BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
When implemented in a derived class, invokes the constructor reflected by this ConstructorInfo with t...
virtual Attribute [] Attributes
Gets the attribute collection.
bool Matches(Attribute[] attributes)
Determines whether the attributes in the specified array are the same as the attributes in the collec...
static AttributeCollection FromExisting(AttributeCollection existing, params Attribute[] newAttributes)
Creates a new T:System.ComponentModel.AttributeCollection from an existing T:System....
int Count
Gets the number of elements contained in the T:System.Collections.ICollection.
Defines size, enumerators, and synchronization methods for all nongeneric collections.
override bool Equals(object obj)
Returns a value that indicates whether this instance is equal to a specified object.
virtual bool IsDefaultAttribute()
When overridden in a derived class, indicates whether the value of this instance is the default value...
Supports a simple iteration over a non-generic collection.