Compartir a través de


CodeDelegate2 Interface

Represents a delegate in source code.

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

Syntax

'Declaration
<GuidAttribute("3B1B24EF-DD8E-4C98-8799-4EFAC80080E9")> _
Public Interface CodeDelegate2 _
    Inherits CodeDelegate
[GuidAttribute("3B1B24EF-DD8E-4C98-8799-4EFAC80080E9")]
public interface CodeDelegate2 : CodeDelegate
[GuidAttribute(L"3B1B24EF-DD8E-4C98-8799-4EFAC80080E9")]
public interface class CodeDelegate2 : CodeDelegate
[<GuidAttribute("3B1B24EF-DD8E-4C98-8799-4EFAC80080E9")>]
type CodeDelegate2 =  
    interface 
        interface CodeDelegate 
    end
public interface CodeDelegate2 extends CodeDelegate

The CodeDelegate2 type exposes the following members.

Properties

  Name Description
Public property Access Sets and gets the access attributes for the specified code delegate.
Public property Attributes Gets a collection of all of the attributes for the delegate.
Public property BaseClass Gets the class from which this CodeDelegate2 object is derived.
Public property Bases Gets a collection of classes from which this item is derived.
Public property Children Gets a collection of objects contained within this CodeDelegate2.
Public property Collection Gets the collection containing the CodeDelegate2 object supporting this property.
Public property Comment Sets and gets the comment associated with the CodeDelegate2.
Public property DerivedTypes Gets a collection of objects derived from the CodeDelegate2 object. Currently not implemented in any of the Visual Studio languages.
Public property DocComment Sets and gets the documentation comments for CodeDelegate element.
Public property DTE Gets the parent object of the delegate, namely a CodeElement2 object.
Public property EndPoint Gets the text point that is the location of the end of the delegate.
Public property Extender Returns the requested Extender for the delegate. Not implemented in Visual C#.
Public property ExtenderCATID Gets the Extender category ID (CATID) for the CodeDelegate object. Not implemented in Visual C#.
Public property ExtenderNames Gets a list of available Extenders for the delegate. Not implemented in Visual C#.
Public property FullName Gets the full path and name of the delegate's file.
Public property InfoLocation Gets the capabilities of the code model for the delegate.
Public property IsCodeType Gets whether or not a CodeType object can be obtained from this delegate.
Public property IsDerivedFrom Indicates whether or not a CodeDelegate2 object has another object as a base.
Public property IsGeneric Gets whether or not the delegate is a generic.
Public property Kind Gets an enumeration that defines the type of object.
Public property Language Gets the programming language used to author the delegate.
Public property Members Gets the collection of items this CodeDelegate2 element contains. Not implemented in Visual Basic.
Public property Name Sets and gets the name of the CodeDelegate2 object.
Public property Namespace Gets an object defining the parent namespace of the delegate.
Public property Parameters Gets a collection of parameters for this CodeDelegate2.
Public property Parent Gets the immediate parent object of a CodeDelegate2 object.
Public property ProjectItem Gets the ProjectItem object associated with the CodeDelegate2 object.
Public property Prototype Returns a string holding the stub definition of this delegate.
Public property StartPoint Gets a TextPoint object that defines the beginning of the delegate.
Public property Type Sets or gets an object representing the programmatic type of the delegate.

Top

Methods

  Name Description
Public method AddAttribute Creates a new attribute code construct and inserts the code in the correct location.
Public method AddBase Adds an item to the list of inherited delegates. This method is not implemented in Visual Basic.
Public method AddParameter Creates a new parameter for the delegate and inserts the code in the correct location.
Public method GetEndPoint Returns a TextPoint object that marks the end of the delegate definition.
Public method GetStartPoint Returns a TextPoint object that defines the beginning of the delegate definition.
Public method RemoveBase Removes the delegate from the list of bases. This method is not implemented in Visual Basic.
Public method RemoveMember Removes a member from the delegate.
Public method RemoveParameter Removes a parameter from the delegate's argument list.

Top

Remarks

This object derives from CodeDelegate.

Note

The values of code model elements such as classes, structs, functions, attributes, delegates, and so forth can be non-deterministic after making certain kinds of edits, meaning that their values cannot be relied upon to always remain the same. For more information, see the section Code Model Element Values Can Change in Discovering Code by Using the Code Model (Visual Basic).

Examples

[VisualBasic]

Sub codeDelegateExample(ByVal dte As DTE2)

    ' Before running this example, open a code document from a project
    ' and place the insertion point inside a variable definition.
    Try
        ' Retrieve the CodeVariable at the insertion point.
        Dim sel As TextSelection = _
            CType(dte.ActiveDocument.Selection, TextSelection)
        Dim del As CodeDelegate2 = _
            CType(sel.ActivePoint.CodeElement( _
            vsCMElement.vsCMElementVariable), CodeDelegate2)

        ' Display the base class name of the delegate.
        MsgBox("Delegate's base class name: " & del.BaseClass.Name)

    Catch ex As Exception
        MsgBox(ex.Message)
    End Try
End Sub

public void codeDelegateExample(DTE2 dte)

[C#]

{
   // Before running this example, open a code document from a
   // project and place the insertion point inside a delegate 
   // declaration.
   try
   {
      TextSelection objTextSel;
      CodeDelegate objCodeDel;
      CodeElement objCodeElem;

      objTextSel = (TextSelection)dte.ActiveDocument.Selection;
      objCodeDel = 
      (CodeDelegate)objTextSel.ActivePoint.
      get_CodeElement(vsCMElement.vsCMElementDelegate);

      // Display the fullname of the CodeDelegate object.
      MessageBox.Show(objCodeDel.FullName);

      // Prove that the parent object of a CodeClass is a CodeElement.
      objCodeElem = (CodeElement)objCodeDel.Parent;
   }
   catch (Exception ex)
   {
      MessageBox.Show(ex.Message);
   }
}

See Also

Reference

EnvDTE80 Namespace

Other Resources

How to: Compile and Run the Automation Object Model Code Examples

Discovering Code by Using the Code Model (Visual Basic)

Discovering Code by Using the Code Model (Visual C#)