Proprietà CodeAttribute2.StartPoint

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

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

Sintassi

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

Valore proprietà

Tipo: EnvDTE.TextPoint
Restituisce un oggetto TextPoint oggetto.

Note

[!NOTA]

I valori degli elementi del modello di codice come classi, strutture, le funzioni, gli attributi, delegati, e così via possono non essere deterministici dopo l'inserimento di determinati tipi di modifiche, pertanto i relativi valori non possono essere basati su per rimanere sempre gli stessi.Per ulteriori informazioni, vedere i valori degli elementi del modello di codice della sezione può cambiare in Individuazione di codice mediante il modello di codice (Visual Basic).

Esempi

Nell'esempio seguente viene creato un nuovo spazio dei nomi e l'attributo nella classe corrente e vengono elencate alcune delle 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#)