System.Reflection.ICustomAttributeProvider Interface

Assembly: Mscorlib.dll
Namespace: System.Reflection
Summary
Provides custom attributes for reflection objects that support them.
C# Syntax:
public interface ICustomAttributeProvider
Remarks
Nearly all the Reflection classes can have attributes associated with them. Attributes can be standard (public, private, HelpString) or custom.
See also:
System.Reflection Namespace

System.Reflection.ICustomAttributeProvider Member List:

Public Methods
GetCustomAttributes Overloaded:
GetCustomAttributes(bool inherit)

Returns an array of all of the custom attributes defined on this member, excluding named attributes, or an empty array if there are no custom attributes.
GetCustomAttributes Overloaded:
GetCustomAttributes(Type attributeType, bool inherit)

Returns an array of custom attributes defined on this member, identified by type, or an empty array if there are no custom attributes of that type.
IsDefined Indicates whether one or more instance of attributeType is defined on this member.

System.Reflection.ICustomAttributeProvider Member Details

Overloaded Method: GetCustomAttributes(
   bool inherit
)
Summary
Returns an array of all of the custom attributes defined on this member, excluding named attributes, or an empty array if there are no custom attributes.
C# Syntax:
object[] GetCustomAttributes(
   bool inherit
);
Parameters:

inherit

When true, look up the hierarchy chain for the inherited custom attribute.

Return Value:
An array of Objects representing custom attributes, or an empty array.
Exceptions
Exception Type Condition
TypeLoadException The custom attribute type cannot be loaded.
AmbiguousMatchException There is more than one attribute of type attributeType defined on this member.
Remarks
Calling ICustomAttributeProvider.GetCustomAttributes on PropertyInfo or EventInfo when the inherit parameter of GetCustomAttributes is true does not walk the type hierarchy. Use Attribute to inherit custom attributes.

This method returns custom attributes defined directly on a non-inherited member only.

Return to top


Overloaded Method: GetCustomAttributes(
   Type attributeType,
   bool inherit
)
Summary
Returns an array of custom attributes defined on this member, identified by type, or an empty array if there are no custom attributes of that type.
C# Syntax:
object[] GetCustomAttributes(
   Type attributeType,
   bool inherit
);
Parameters:

attributeType

The type of the custom attributes.

inherit

When true, look up the hierarchy chain for the inherited custom attribute.

Return Value:
An array of Objects representing custom attributes, or an empty array.
Exceptions
Exception Type Condition
TypeLoadException The custom attribute type cannot be loaded.
AmbiguousMatchException There is more than one attribute of type attributeType defined on this member.
Remarks
If attributeType is a base class or interface, this method returns any implementation of that type.

This method returns custom attributes defined directly on a non-inherited member only.

Calling ICustomAttributeProvider.GetCustomAttributes on PropertyInfo or EventInfo when the inherit parameter of GetCustomAttributes is true does not walk the type hierarchy. Use Attribute to inherit custom attributes.

Return to top


Method: IsDefined(
   Type attributeType,
   bool inherit
)
Summary
Indicates whether one or more instance of attributeType is defined on this member.
C# Syntax:
bool IsDefined(
   Type attributeType,
   bool inherit
);
Parameters:

attributeType

The type of the custom attributes.

inherit

When true, look up the hierarchy chain for the inherited custom attribute.

Return Value:
true if the attributeType is defined on this member; false otherwise.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.