Share via


CodeDelegate2 接口

表示源代码中的委托。

命名空间:  EnvDTE80
程序集:  EnvDTE80(在 EnvDTE80.dll 中)

语法

声明
<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

CodeDelegate2 类型公开以下成员。

属性

  名称 说明
公共属性 Access 设置并获取指定代码委托的访问特性。
公共属性 Attributes 获取委托的所有特性的集合。
公共属性 BaseClass 获取此 CodeDelegate2 对象派生自的类。
公共属性 Bases 获取此项派生自的类的集合。
公共属性 Children 获取此 CodeDelegate2 中包含的对象的集合。
公共属性 Collection 获取包含支持此属性的 CodeDelegate2 对象的集合。
公共属性 Comment 设置并获取与 CodeDelegate2 关联的注释。
公共属性 DerivedTypes 获取从 CodeDelegate2 对象派生的对象的集合。目前未在任何 Visual Studio 语言中实现。
公共属性 DocComment 设置并获取 CodeDelegate 元素的文档注释。
公共属性 DTE 获取该委托的父对象,即 CodeElement2 对象。
公共属性 EndPoint 获取表示委托结束位置的文本点。
公共属性 Extender 返回请求的该委托的 Extender。未在 Visual C# 中实现。
公共属性 ExtenderCATID 获取 CodeDelegate 对象的扩展程序类别 ID (CATID)。未在 Visual C# 中实现。
公共属性 ExtenderNames 获取委托的可用扩展程序的列表。未在 Visual C# 中实现。
公共属性 FullName 获取委托文件的完整路径和名称。
公共属性 InfoLocation 获取委托的代码模型的功能。
公共属性 IsCodeType 获取是否可以从此委托中获取 CodeType 对象。
公共属性 IsDerivedFrom 指示 CodeDelegate2 对象是否以另一个对象作为基。
公共属性 IsGeneric 获取委托是否为泛型。
公共属性 Kind 获取一个枚举,该枚举定义对象的类型。
公共属性 Language 获取用于创作委托的编程语言。
公共属性 Members 获取该 CodeDelegate2 元素包含的项的集合。未在 Visual Basic 中实现。
公共属性 Name 设置并获取 CodeDelegate2 对象的名称。
公共属性 Namespace 获取一个对象,该对象定义委托的父命名空间。
公共属性 Parameters 获取该 CodeDelegate2 的参数集合。
公共属性 Parent 获取 CodeDelegate2 对象的直接父对象。
公共属性 ProjectItem 获取与该 CodeDelegate2 对象关联的 ProjectItem 对象。
公共属性 Prototype 返回一个字符串,该字符串包含此委托的存根 (stub) 定义。
公共属性 StartPoint 获取一个 TextPoint 对象,该对象定义委托的开始位置。
公共属性 Type 设置或获取表示委托的编程类型的对象。

页首

方法

  名称 说明
公共方法 AddAttribute 创建新的特性代码构造,并将代码插入正确的位置。
公共方法 AddBase 将某项继添加到继承委托的列表中。此方法未在 Visual Basic 中实现。
公共方法 AddParameter 为委托创建新的参数,并将代码插入正确的位置。
公共方法 GetEndPoint 返回一个 TextPoint 对象,该对象标记委托定义的结束位置。
公共方法 GetStartPoint 返回一个 TextPoint 对象,该对象定义委托定义的开始位置。
公共方法 RemoveBase 从基列表中移除该委托。此方法未在 Visual Basic 中实现。
公共方法 RemoveMember 从委托中移除成员。
公共方法 RemoveParameter 从委托的参数列表中移除一个参数。

页首

备注

此对象派生自 CodeDelegate

备注

在进行某些类型的编辑之后,代码模型元素(如类、结构、函数、特性、委托等)的值可能是非确定性的,这意味着不能指望它们的值总是保持不变。有关更多信息,请参见 使用代码模型查找代码 (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

公共 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);
   }
}

请参阅

参考

EnvDTE80 命名空间

其他资源

如何:编译和运行自动化对象模型代码示例

使用代码模型查找代码 (Visual Basic)

使用代码模型查找代码 (Visual C#)