System.Reflection.CustomAttributeTypedArgument Structure

Represents an argument of a custom attribute in the reflection-only context, or an element of an array argument.

See Also: CustomAttributeTypedArgument Members


public struct CustomAttributeTypedArgument


Code that is being examined in the reflection-only context cannot be executed, so it is not always possible to examine custom attributes by creating instances of them and then examining their properties, using methods like erload:System.Attribute.GetCustomAttributes, erload:System.Reflection.MemberInfo.GetCustomAttributes, and so on. If the code for the attribute type itself is loaded into the reflection-only context, it cannot be executed.

The System.Reflection.CustomAttributeNamedArgument structure is used by the System.Reflection.CustomAttributeData class to provide access to the type and value of a positional argument specified for a custom attribute instance, without executing the attribute constructor. It also provides access to the type and value of a named argument without executing the code of the corresponding property of the custom attribute type.

The types and values of all the positional and named arguments of an attribute instance are provided by System.Reflection.CustomAttributeTypedArgument structures. The positional attributes returned by the CustomAttributeData.ConstructorArguments property are directly represented by System.Reflection.CustomAttributeTypedArgument structures, but the named arguments returned by the CustomAttributeData.NamedArguments property are represented by System.Reflection.CustomAttributeNamedArgument structures; to get the System.Reflection.CustomAttributeTypedArgument structure for a named argument, use the CustomAttributeNamedArgument.TypedValue property.

If an argument is an array of values, the CustomAttributeTypedArgument.Value property of the System.Reflection.CustomAttributeTypedArgument that represents the argument returns a generic System.Collections.ObjectModel.ReadOnlyCollection`1 of System.Reflection.CustomAttributeTypedArgument objects. Each System.Reflection.CustomAttributeTypedArgument object in the collection represents the corresponding element of the array.

To create instances of the System.Reflection.CustomAttributeData class, use the static erload:System.Reflection.CustomAttributeData.GetCustomAttributes factory method.


Namespace: System.Reflection
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions:,
Since: .NET 2.0