CodeAttributeDeclaration Class
Represents an attribute declaration.
Assembly: System (in System.dll)
The CodeAttributeDeclaration type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | CodeAttributeDeclaration() | Initializes a new instance of the CodeAttributeDeclaration class. |
![]() | CodeAttributeDeclaration(CodeTypeReference) | Initializes a new instance of the CodeAttributeDeclaration class using the specified code type reference. |
![]() | CodeAttributeDeclaration(String) | Initializes a new instance of the CodeAttributeDeclaration class using the specified name. |
![]() | CodeAttributeDeclaration(CodeTypeReference, array<CodeAttributeArgument>) | Initializes a new instance of the CodeAttributeDeclaration class using the specified code type reference and arguments. |
![]() | CodeAttributeDeclaration(String, array<CodeAttributeArgument>) | Initializes a new instance of the CodeAttributeDeclaration class using the specified name and arguments. |
| Name | Description | |
|---|---|---|
![]() | Arguments | Gets the arguments for the attribute. |
![]() | AttributeType | Gets the code type reference for the code attribute declaration. |
![]() | Name | Gets or sets the name of the attribute being declared. |
| Name | Description | |
|---|---|---|
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | 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 a string that represents the current object. (Inherited from Object.) |
A CodeAttributeDeclaration can be used to represent an expression that declares an attribute. The attribute name and the arguments for the attribute are stored as properties of the object. A CodeAttributeArgument can be used to represent each argument for the attribute.
The following code example creates a CodeAttributeDeclaration that declares a CLSCompliantAttribute with an argument of false:
#using <System.dll> #using <System.Xml.dll> using namespace System; using namespace System::CodeDom; using namespace System::CodeDom::Compiler; int main() { // Declare a new type called Class1. CodeTypeDeclaration^ class1 = gcnew CodeTypeDeclaration("Class1"); // Declare a new code attribute CodeAttributeDeclaration^ codeAttrDecl = gcnew CodeAttributeDeclaration( "System.CLSCompliantAttribute", gcnew CodeAttributeArgument(gcnew CodePrimitiveExpression(false))); class1->CustomAttributes->Add(codeAttrDecl); // Create a C# code provider CodeDomProvider^ provider = CodeDomProvider::CreateProvider("CSharp"); // Generate code and send the output to the console provider->GenerateCodeFromType(class1, Console::Out, gcnew CodeGeneratorOptions()); } // The CPP code generator produces the following source code for the preceeding example code: // //[System.CLSCompliantAttribute(false)] //public class Class1 { //}
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
