CodeAttributeDeclaration 클래스

정의

특성 선언을 나타냅니다.

public ref class CodeAttributeDeclaration
public class CodeAttributeDeclaration
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class CodeAttributeDeclaration
type CodeAttributeDeclaration = class
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type CodeAttributeDeclaration = class
Public Class CodeAttributeDeclaration
상속
CodeAttributeDeclaration
특성

예제

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 {
//}
using System;
using System.CodeDom;
using System.CodeDom.Compiler;

public class CodeGenExample
{
    static void Main()
    {
        // Declare a new type called Class1.
        CodeTypeDeclaration class1 = new CodeTypeDeclaration("Class1");

        // Declare a new code attribute
        CodeAttributeDeclaration codeAttrDecl = new CodeAttributeDeclaration(
            "System.CLSCompliantAttribute",
            new CodeAttributeArgument(new 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, new CodeGeneratorOptions());
    }
}

// The C# code generator produces the following source code for the preceeding example code:
//
// [System.CLSCompliantAttribute(false)]
// public class Class1 {
// }
Imports System.CodeDom
Imports System.CodeDom.Compiler

Public Class CodeGenExample

    Shared Sub Main
        ' Declare a new type called Class1.
        Dim class1 as New CodeTypeDeclaration("Class1")

        '  Declare a new code attribute
        Dim codeAttrDecl As New CodeAttributeDeclaration(
            "System.CLSCompliantAttribute",
            new CodeAttributeArgument(new CodePrimitiveExpression(false)))
        class1.CustomAttributes.Add(codeAttrDecl)

        ' Create a Visual Basic code provider
        Dim provider As CodeDomProvider = CodeDomProvider.CreateProvider("VisualBasic")

        ' Generate code and send the output to the console
        provider.GenerateCodeFromType(class1, Console.Out, New CodeGeneratorOptions())
    End Sub

End Class

' The Visual Basic code generator produces the following source code for the preceeding example code:
'
' <System.CLSCompliantAttribute(false)>  _
' Public Class Class1
' End Class

설명

A CodeAttributeDeclaration 는 특성을 선언하는 식을 나타내는 데 사용할 수 있습니다. 특성 이름 및 특성의 인수는 개체의 속성으로 저장됩니다. A CodeAttributeArgument 는 특성의 각 인수를 나타내는 데 사용할 수 있습니다.

생성자

CodeAttributeDeclaration()

CodeAttributeDeclaration 클래스의 새 인스턴스를 초기화합니다.

CodeAttributeDeclaration(CodeTypeReference)

지정된 코드 형식 참조를 사용하여 CodeAttributeDeclaration 클래스의 새 인스턴스를 초기화합니다.

CodeAttributeDeclaration(CodeTypeReference, CodeAttributeArgument[])

지정된 코드 형식 참조 및 인수를 사용하여 CodeAttributeDeclaration 클래스의 새 인스턴스를 초기화합니다.

CodeAttributeDeclaration(String)

지정한 이름을 사용하여 CodeAttributeDeclaration 클래스의 새 인스턴스를 초기화합니다.

CodeAttributeDeclaration(String, CodeAttributeArgument[])

지정된 이름과 인수를 사용하여 CodeAttributeDeclaration 클래스의 새 인스턴스를 초기화합니다.

속성

Arguments

특성의 인수를 가져옵니다.

AttributeType

코드 특성 선언에 대한 코드 형식 참조를 가져옵니다.

Name

선언하는 특성의 이름을 가져오거나 설정합니다.

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상

추가 정보