CodeAttributeDeclaration Sınıf

Tanım

Öznitelik bildirimini temsil eder.

public ref class CodeAttributeDeclaration
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class CodeAttributeDeclaration
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type CodeAttributeDeclaration = class
Public Class CodeAttributeDeclaration
Devralma
CodeAttributeDeclaration
Öznitelikler

Örnekler

Aşağıdaki kod örneği, CodeAttributeDeclaration bağımsız değişkeniyle falsebir bildiren bir CLSCompliantAttribute oluşturur:

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çıklamalar

bir CodeAttributeDeclaration özniteliğini bildiren bir ifadeyi temsil etmek için kullanılabilir. Özniteliğin öznitelik adı ve bağımsız değişkenleri nesnenin özellikleri olarak depolanır. özniteliği CodeAttributeArgument için her bağımsız değişkeni temsil etmek için A kullanılabilir.

Oluşturucular

Name Description
CodeAttributeDeclaration()

CodeAttributeDeclaration sınıfının yeni bir örneğini başlatır.

CodeAttributeDeclaration(CodeTypeReference, CodeAttributeArgument[])

Belirtilen kod türü başvuru ve bağımsız değişkenlerini kullanarak sınıfın yeni bir örneğini CodeAttributeDeclaration başlatır.

CodeAttributeDeclaration(CodeTypeReference)

Belirtilen kod türü başvuruyu kullanarak sınıfın CodeAttributeDeclaration yeni bir örneğini başlatır.

CodeAttributeDeclaration(String, CodeAttributeArgument[])

Belirtilen adı ve bağımsız değişkenleri kullanarak sınıfın CodeAttributeDeclaration yeni bir örneğini başlatır.

CodeAttributeDeclaration(String)

Belirtilen adı kullanarak sınıfın CodeAttributeDeclaration yeni bir örneğini başlatır.

Özellikler

Name Description
Arguments

Özniteliğin bağımsız değişkenlerini alır.

AttributeType

Kod özniteliği bildirimi için kod türü başvuruyu alır.

Name

Bildirilen özniteliğin adını alır veya ayarlar.

Yöntemler

Name Description
Equals(Object)

Belirtilen nesnenin geçerli nesneye eşit olup olmadığını belirler.

(Devralındığı yer: Object)
GetHashCode()

Varsayılan karma işlevi işlevi görür.

(Devralındığı yer: Object)
GetType()

Geçerli örneğin Type alır.

(Devralındığı yer: Object)
MemberwiseClone()

Geçerli Objectbasit bir kopyasını oluşturur.

(Devralındığı yer: Object)
ToString()

Geçerli nesneyi temsil eden bir dize döndürür.

(Devralındığı yer: Object)

Şunlara uygulanır

Ayrıca bkz.