Condividi tramite


Proprietà CodeDelegate2.BaseClass

ottiene la classe da cui questo CodeDelegate2 l'oggetto viene derivato da.

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

Sintassi

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

Valore proprietà

Tipo: EnvDTE.CodeClass
In CodeClass oggetto.

Note

restituisce CodeClass oggetto per com.ms.system.delegate.

[!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

Prima di eseguire questo esempio, caricare un progetto con una classe e inserire la seguente riga con il codice di esempio.Dopo la riga che il codice di esempio vengono aggiunte, fare clic su Delegate true per posizionare il punto di inserimento altri e quindi eseguire l'esempio.

[Visual Basic]

Delegate Sub MySubDelegate(ByVal x As Integer)

[C#]

public delegate void MySubDelegate(int x);

[Visual Basic]

Public Sub CodeDelegateExample(ByVal dte As DTE2)
    ' Before running this example, open a code document from a 
    ' project and place the insertion point inside a class 
    ' definition.
    Try
        ' Retrieve the CodeClass at the insertion point.
        Dim sel As TextSelection = _
            CType(DTE.ActiveDocument.Selection, TextSelection)
        Dim del As CodeDelegate2 = _
            CType(sel.ActivePoint.CodeElement( _
        vsCMElement.vsCMElementDelegate), CodeDelegate2)
        Dim elem As CodeElement2
        Dim sb As New System.Text.StringBuilder

        ' Display the baseclass name of the delegate.
        sb.AppendLine("Delegate base class name: " & _
          del.BaseClass.Name)
        sb.AppendLine("Delegate's access: " & del.Access.ToString)
        sb.AppendLine("Children: " & del.Children.Count & "  _
          Name: " & del.Children.Item(1).Name)
        sb.AppendLine("Collection: " & del.Collection.Count)
        sb.AppendLine("Delegates:")
        For Each elem In del.Collection
            sb.AppendLine("    - " & elem.Name)
        Next
        sb.AppendLine("Comment: " & del.Comment)
        sb.AppendLine("Doc Comment: " & del.DocComment)
        sb.AppendLine("DTE Parent: " & del.DTE.Name)
        sb.AppendLine("Endpoint location: " & _
          del.EndPoint.AbsoluteCharOffset)
        sb.AppendLine("Infolocation: " & del.InfoLocation.ToString)
        sb.AppendLine("Can provide CodeType object? " & _
          del.IsCodeType.ToString)
        sb.AppendLine("Is Delegate derived? " & _
          del.IsDerivedFrom("EnvDTE80"))
        sb.AppendLine("Is Delegate a generic? " & del.IsGeneric)
        sb.AppendLine("Kind: " & del.Kind.ToString)
        sb.AppendLine("Authoring language: " & _
          del.Language.ToString)
        sb.AppendLine("Name: " & del.Name)
        sb.AppendLine("Namespace: " + del.Namespace.Name);
        sb.AppendLine("Parameters: " & del.Parameters.Item(1).Name)
        sb.AppendLine("Project containing the delegate: " & _
          del.ProjectItem.Name)
        sb.AppendLine("Prototype for delegate: " & del.Prototype)
        sb.AppendLine("Delegate start point offset: " & _
          del.StartPoint.LineCharOffset)
        sb.AppendLine("Type: " & del.Type.TypeKind.ToString)
        MsgBox(sb.ToString)

    Catch ex As System.Exception
        MsgBox(ex.ToString)
    End Try
End Sub

[C#]

public void CodeDelegateExample(DTE2 DTE)
{
    try
    {
        // Retrieve the CodeClass at the insertion point.
        TextSelection sel = (TextSelection) 
          DTE.ActiveDocument.Selection;
        CodeDelegate2 del = (CodeDelegate2) 
          sel.ActivePoint.get_CodeElement
          (vsCMElement.vsCMElementDelegate);
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        // Display the baseclass name of the delegate.
        sb.AppendLine("Delegate base class name: " + 
          del.BaseClass.Name);
        sb.AppendLine("Delegate's access: " + del.Access);
        sb.AppendLine("Children: "+del.Children.Count+"  Name: 
          "+del.Children.Item(1).Name);
        sb.AppendLine("Collection: "+del.Collection.Count);
        sb.AppendLine("Delegates:");
        foreach (CodeElement2 elem in del.Collection )
        {
            sb.AppendLine("    - "+elem.Name);
        }
        sb.AppendLine("Comment: "+del.Comment);
        sb.AppendLine("Attributes:"); 
        foreach (CodeElement2 elem in del.Attributes)
        {
            sb.AppendLine("    - " + elem.Name);
        }
        sb.AppendLine("Bases:");
        foreach (CodeElement2 elem in del.Bases)
        {
            sb.AppendLine("    - " + elem.Name);
        } 
        sb.AppendLine("Doc Comment: " + del.DocComment);
        sb.AppendLine("DTE Parent: "+del.DTE.Name);
        sb.AppendLine("Endpoint location: 
          "+del.EndPoint.AbsoluteCharOffset);
        sb.AppendLine("Infolocation: "+del.InfoLocation);
        sb.AppendLine("Can provide CodeType object? "+del.IsCodeType);
        sb.AppendLine("Is Delegate derived? 
          "+del.get_IsDerivedFrom("EnvDTE80"));
        sb.AppendLine("Is Delegate a generic? "+del.IsGeneric);
        sb.AppendLine("Kind: "+del.Kind);
        sb.AppendLine("Authoring language: "+del.Language);
        sb.AppendLine("Name: "+del.Name);
        sb.AppendLine("Parameters: "+del.Parameters.Item(1).Name);
        sb.AppendLine("Namespace: " + del.Namespace.Name);
        sb.AppendLine("Project containing the delegate: 
          "+del.ProjectItem.Name);
        sb.AppendLine("Delegate start point offset: 
          "+del.StartPoint.LineCharOffset);
        sb.AppendLine("Type: "+del.Type.TypeKind);
          MessageBox.Show(sb.ToString());
    }
    catch(System.Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

Sicurezza di .NET Framework

Vedere anche

Riferimenti

CodeDelegate2 Interfaccia

Overload BaseClass

Spazio dei nomi EnvDTE80

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#)