CodeAttribute2.Language Eigenschaft

Definition

Ruft eine Konstante ab, die die zum Schreiben des Attributs verwendete Programmiersprache identifiziert.

public:
 property System::String ^ Language { System::String ^ get(); };
public:
 property Platform::String ^ Language { Platform::String ^ get(); };
[System.Runtime.InteropServices.DispId(9)]
public string Language { [System.Runtime.InteropServices.DispId(9)] [System.Runtime.InteropServices.TypeLibFunc(1024)] get; }
[<System.Runtime.InteropServices.DispId(9)>]
[<get: System.Runtime.InteropServices.DispId(9)>]
[<get: System.Runtime.InteropServices.TypeLibFunc(1024)>]
member this.Language : string
Public ReadOnly Property Language As String

Eigenschaftswert

String

Gibt eine CodeModelLanguageConstants-Auflistung zurück.

Implementiert

Attribute

Beispiele

Im folgenden Beispiel werden ein neuer Namespace und ein neues Attribut in der aktuellen Klasse erstellt und einige Eigenschaften des Attributs aufgelistet.

public void CreateClassAndAttrib(DTE2 applicationObject)  
{  
    // Before running, load or create a project.  
    FileCodeModel2 fcm2 = GetFileCodeModel(applicationObject);  
    CodeAttribute2 cmAttribute;  
    CodeClass2 cmClass;  
    String msg = null;  

    if (fcm2 != null)  
    {  
        CodeNamespace cmNamespace;  
        // Try to create a new namespace.  
        try  
        {  
            cmNamespace = fcm2.AddNamespace("CMNamespace", -1);  
            // If successful, create the other code elements.  
            if (cmNamespace != null)  
            {  
                cmClass = (CodeClass2)cmNamespace.AddClass("ANewClass",   
                -1, null, null, vsCMAccess.vsCMAccessPrivate);  
                cmAttribute = (CodeAttribute2)cmClass.AddAttribute  
                ("NewAttribute", "AttributeValue", -1);  
                msg += "Language: " + cmAttribute.Language +   
                Environment.NewLine;  
                msg += "Name: " + cmAttribute.Name +   
                Environment.NewLine;  
                msg += "Parent: " + cmAttribute.Parent +   
                Environment.NewLine;  
                MessageBox.Show(msg);                         
            }  
            else  
            {  
                MessageBox.Show("Cannot continue - no filecodemodel   
                available.");  
            }  
        }  
        catch (Exception ex)  
        {  
            MessageBox.Show("ERROR: " + ex);  
        }  
    }  
}  

public FileCodeModel2 GetFileCodeModel(DTE2 applicationObject)  
{  
    // Returns the FileCodeModel object of the active   
    // window.  
    TextWindow txtWin =   
    (TextWindow)applicationObject.ActiveWindow.Object;  
    FileCodeModel2 fcm2;  
    if (txtWin != null)  
    {  
        try  
        {  
             fcm2 = (FileCodeModel2)txtWin.Parent.  
             ProjectItem.FileCodeModel;  
             return fcm2;  
        }  
        catch (Exception ex)  
        {  
             MessageBox.Show("ERROR: " + ex);  
             return null;  
        }  
    }  
    else  
        return null;  
}  

Hinweise

Hinweis

Die Werte von Codemodellelementen wie z. B. Klassen, Strukturen, Funktionen, Attributen Delegaten usw. sind nach bestimmten Änderungen unter Umständen nicht deterministisch, d. h. deren Werte bleiben nicht zuverlässig immer gleich. Weitere Informationen finden Sie im Abschnitt Code Modell Element-Werte können sich in ermitteln von Code mithilfe des Code Modells (Visual Basic)ändern.

Gilt für