Export (0) Print
Expand All

CodeDelegate2 Interface

Represents a delegate in source code.

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

[GuidAttribute("3B1B24EF-DD8E-4C98-8799-4EFAC80080E9")]
public interface CodeDelegate2 : CodeDelegate

The CodeDelegate2 type exposes the following members.

  NameDescription
Public propertyAccessSets and gets the access attributes for the specified code delegate.
Public propertyAttributesGets a collection of all of the attributes for the delegate.
Public propertyBaseClassGets the class from which this CodeDelegate2 object is derived.
Public propertyBasesGets a collection of classes from which this item is derived.
Public propertyChildrenGets a collection of objects contained within this CodeDelegate2.
Public propertyCollectionGets the collection containing the CodeDelegate2 object supporting this property.
Public propertyCommentSets and gets the comment associated with the CodeDelegate2.
Public propertyDerivedTypesGets a collection of objects derived from the CodeDelegate2 object. Currently not implemented in any of the Visual Studio languages.
Public propertyDocCommentSets and gets the documentation comments for CodeDelegate element.
Public propertyDTEGets the parent object of the delegate, namely a CodeElement2 object.
Public propertyEndPointGets the text point that is the location of the end of the delegate.
Public propertyExtenderReturns the requested Extender for the delegate. Not implemented in Visual C#.
Public propertyExtenderCATIDGets the Extender category ID (CATID) for the CodeDelegate object. Not implemented in Visual C#.
Public propertyExtenderNamesGets a list of available Extenders for the delegate. Not implemented in Visual C#.
Public propertyFullNameGets the full path and name of the delegate's file.
Public propertyInfoLocationGets the capabilities of the code model for the delegate.
Public propertyIsCodeTypeGets whether or not a CodeType object can be obtained from this delegate.
Public propertyIsDerivedFromIndicates whether or not a CodeDelegate2 object has another object as a base.
Public propertyIsGenericGets whether or not the delegate is a generic.
Public propertyKindGets an enumeration that defines the type of object.
Public propertyLanguageGets the programming language used to author the delegate.
Public propertyMembersGets the collection of items this CodeDelegate2 element contains. Not implemented in Visual Basic.
Public propertyNameSets and gets the name of the CodeDelegate2 object.
Public propertyNamespaceGets an object defining the parent namespace of the delegate.
Public propertyParametersGets a collection of parameters for this CodeDelegate2.
Public propertyParentGets the immediate parent object of a CodeDelegate2 object.
Public propertyProjectItemGets the ProjectItem object associated with the CodeDelegate2 object.
Public propertyPrototypeReturns a string holding the stub definition of this delegate.
Public propertyStartPointGets a TextPoint object that defines the beginning of the delegate.
Public propertyTypeSets or gets an object representing the programmatic type of the delegate.
Top

  NameDescription
Public methodAddAttributeCreates a new attribute code construct and inserts the code in the correct location.
Public methodAddBaseAdds an item to the list of inherited delegates. This method is not implemented in Visual Basic.
Public methodAddParameterCreates a new parameter for the delegate and inserts the code in the correct location.
Public methodGetEndPointReturns a TextPoint object that marks the end of the delegate definition.
Public methodGetStartPointReturns a TextPoint object that defines the beginning of the delegate definition.
Public methodRemoveBaseRemoves the delegate from the list of bases. This method is not implemented in Visual Basic.
Public methodRemoveMemberRemoves a member from the delegate.
Public methodRemoveParameterRemoves a parameter from the delegate's argument list.
Top

This object derives from CodeDelegate.

NoteNote

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

[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);
   }
}

Community Additions

ADD
Show:
© 2014 Microsoft