Share via


Expression.Collection 属性

获取包含某个对象的集合,该对象支持此属性或包含在此代码构造中。

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

语法

声明
ReadOnly Property Collection As Expressions
Expressions Collection { get; }
property Expressions^ Collection {
    Expressions^ get ();
}
abstract Collection : Expressions with get
function get Collection () : Expressions

属性值

类型:EnvDTE.Expressions
Expressions 集合。

示例

下面的示例演示如何使用 Collection 属性。

测试此属性:

  1. 目标应用程序必须包含类 A。 函数 Main 必须创建类 A 的一个实例“a”。

  2. 在创建了类 A 的一个实例并初始化其成员变量后,在函数 Main 中设置一个断点。

  3. 以调试模式运行目标应用程序。

  4. 当此应用程序停在该断点处时,运行外接程序。

public static void Collection(DTE dte)
{
    // Setup debug Output window.
    Window w = (Window)dte.Windows.Item(EnvDTE.Constants.vsWindowKindOutput);
    w.Visible = true;
    OutputWindow ow = (OutputWindow)w.Object;
    OutputWindowPane owp = ow.OutputWindowPanes.Add("Collection Property Test");
    owp.Activate();

    EnvDTE.Expression exp = dte.Debugger.GetExpression("a", true, 1);
    EnvDTE.Expressions exps = exp.DataMembers;
    owp.OutputString("\nExpression count: " + exps.Count);
    owp.OutputString("\nEdition of the environment: " + exps.DTE.Edition);
    owp.OutputString("\nThe name of the current program: " + 
                     exps.Parent.CurrentProgram.Name);
    owp.OutputString("\nSecond expression: " + exps.Item(2).Name);
}
Shared Sub Collection(ByRef dte As EnvDTE.DTE)
    Dim exp As EnvDTE.Expression = dte.Debugger.GetExpression("a", True, 1)
    Dim exps As EnvDTE.Expressions = exp.DataMembers
    Dim str As String = vbCrLf
    str = "Expression count: " + exps.Count.ToString()
    str += vbCrLf + "Edition of the environment: " + exps.DTE.Edition
    str += vbCrLf + "The name of the current program: " + _
           exps.Parent.CurrentProgram.Name
    str += vbCrLf + "Second expression: " + exps.Item(2).Name
    MessageBox.Show(str, "Expression Test - Collection Property")
End Sub

.NET Framework 安全性

请参阅

参考

Expression 接口

EnvDTE 命名空间

其他资源

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