[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Represents a named argument of a custom attribute in the reflection-only context.
Assembly: mscorlib (in mscorlib.dll)
Thetype exposes the following members.
|IsField||Gets a value that indicates whether the named argument is a field.|
|MemberName||Gets the name of the attribute member that would be used to set the named argument.|
|TypedValue||Gets a CustomAttributeTypedArgument structure that can be used to obtain the type and value of the current named argument.|
|Equals||Indicates whether this instance and a specified object are equal. (Inherited from ValueType.)|
|Finalize||Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)|
|GetHashCode||Returns the hash code for this instance. (Inherited from ValueType.)|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|MemberwiseClone||Creates a shallow copy of the current Object. (Inherited from Object.)|
|ToString||Returns the fully qualified type name of this instance. (Inherited from ValueType.)|
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 Attribute.GetCustomAttributes, 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 structure is used by the CustomAttributeData class to provide access to a named argument specified for a custom attribute instance, without executing the code of the corresponding property of the custom attribute type. The TypedValue property returns a CustomAttributeTypedArgument structure that contains the type and value of the named argument.
Whether an argument is named or positional, you must access its type and value by using the CustomAttributeTypedArgument structure.
To create instances of the CustomAttributeData class, use the staticGetCustomAttributes() factory method.
The following example defines a custom attribute with four constructors and four properties. Two of the properties are read-only, and are set by using the positional parameters of the constructors. The other two properties are read/write, and can be set only by using named arguments. One positional property is an array of strings, and one named property is an array of integers.
The attribute is applied to the assembly, to a type declared in the assembly, to a method of the type, and to a parameter of the method. Different constructors are used for these cases. When executed, the assembly loads itself into the reflection-only context and displays information about the custom attributes that were applied to it and to the type and members it contains.
The attribute that is applied to the type demonstrates array properties, with both positional and named arguments.