Proprietà CodeAttribute2.StartPoint

Ottiene un oggetto TextPoint che definisce l'inizio dell'attributo.

Spazio dei nomi:  EnvDTE80
Assembly:  EnvDTE80 (in EnvDTE80.dll)

Sintassi

'Dichiarazione
ReadOnly Property StartPoint As TextPoint
    Get
TextPoint StartPoint { get; }
property TextPoint^ StartPoint {
    TextPoint^ get ();
}
abstract StartPoint : TextPoint
function get StartPoint () : TextPoint

Valore proprietà

Tipo: EnvDTE.TextPoint
Restituisce un oggetto TextPoint.

Implementa

CodeAttribute.StartPoint

Note

Nota

I valori degli elementi del modello di codice, quali classi, strutture, funzioni, attributi, delegati e così via, possono non essere deterministici dopo alcuni tipi di modifiche. Ciò significa che non si può fare affidamento sulla stabilità di tali valori. Per ulteriori informazioni, vedere la sezione Possibile modifica dei valori degli elementi del modello di codice in Individuazione di codice mediante il modello di codice (Visual Basic).

Esempi

Nell'esempio riportato di seguito vengono creati uno spazio dei nomi e un attributo nuovi nella classe corrente e vengono elencate alcune proprietà dell'attributo.

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 += "Project Item Name: " + 
                cmAttribute.ProjectItem.Name + Environment.NewLine;
                msg += "Startpoint DisplayColumn: " + 
                cmAttribute.StartPoint.DisplayColumn + 
                Environment.NewLine;
                msg += "Target: " + cmAttribute.Target + 
                Environment.NewLine;
                msg += "Value: " + cmAttribute.Value + 
                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;
}

Sicurezza di .NET Framework

Vedere anche

Riferimenti

CodeAttribute2 Interfaccia

Overload StartPoint

Spazio dei nomi EnvDTE80

EndPoint

Altre risorse

Procedura: compilare ed eseguire gli esempi di codice del modello a oggetti di automazione

Individuazione di codice mediante il modello di codice (Visual Basic)

Individuazione di codice mediante il modello di codice (Visual C#)