Freigeben über


CodeAttribute2.GetEndPoint-Methode

Gibt ein TextPoint-Objekt zurück, das die Endposition des Attributs markiert.

Namespace:  EnvDTE80
Assembly:  EnvDTE80 (in EnvDTE80.dll)

Syntax

'Declaration
Function GetEndPoint ( _
    Part As vsCMPart _
) As TextPoint
TextPoint GetEndPoint(
    vsCMPart Part
)
TextPoint^ GetEndPoint(
    [InAttribute] vsCMPart Part
)
abstract GetEndPoint : 
        Part:vsCMPart -> TextPoint
function GetEndPoint(
    Part : vsCMPart
) : TextPoint

Parameter

  • Part
    Typ: vsCMPart

    Optional. Eine vsCMPart-Konstante, die den abzurufenden Teil des Attributs angibt.

Rückgabewert

Typ: TextPoint
Ein TextPoint-Objekt.

Hinweise

Hinweis

Die Werte von Codemodellelementen wie Klassen, Strukturen, Funktionen, Attributen, Delegaten usw. können nach bestimmten Bearbeitungsvorgängen nicht deterministisch sein, d. h., dass nicht mehr davon ausgegangen werden kann, dass ihre Werte immer unverändert bleiben.Weitere Informationen finden Sie im Abschnitt zum Änderungsverhalten von Codemodellelementwerten unter Ermitteln von Code über das Codemodell (Visual Basic).

Beispiele

Im folgenden Beispiel werden in der aktuellen Klasse ein neuer Namespace und ein neues Attribut erstellt und einige der Attributeigenschaften 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);
                cmAttribute.GetEndPoint(vsCMPart.vsCMPartAttributes);
                cmAttribute.GetStartPoint(vsCMPart.vsCMPartAttributes);
            }
            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;
}

.NET Framework-Sicherheit

Siehe auch

Referenz

CodeAttribute2 Schnittstelle

EnvDTE80-Namespace

EndPoint

GetEndPoint

Weitere Ressourcen

Gewusst wie: Kompilieren und Ausführen der Codebeispiele für das Automatisierungsobjektmodell

Ermitteln von Code über das Codemodell (Visual Basic)

Ermitteln von Code über das Codemodell (Visual C#)