Share via


Breakpoint.Condition 属性

指定断点的条件。

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

语法

声明
ReadOnly Property Condition As String
string Condition { get; }
property String^ Condition {
    String^ get ();
}
abstract Condition : string with get
function get Condition () : String

属性值

类型:String
表示属性的断点条件的字符串。

备注

条件是一个可选属性,用于确定当到达断点时程序是否中断。 在“断点条件”对话框中指定此条件。

返回字符串通常是一个表达式,用于确定断点的点击时间。

示例

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

测试此属性:

  1. 运行外接程序。

  2. 运行目标应用程序。

public static void Condition(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("Breakpoint Condition Test: ");
    owp.Activate();
    
    //dte is a reference to the DTE object passed to you by the
    //OnConnection method that you implement when you create an add-in.
    EnvDTE.Debugger debugger = (EnvDTE.Debugger)dte.Debugger;
    //Stop at the breakpoint if TempC < TempF is true
    debugger.Breakpoints.Add("","Target001.cs", 15, 1, "tempC < tempF", 
    EnvDTE.dbgBreakpointConditionType.dbgBreakpointConditionTypeWhenTrue, 
    "C#","", 0, "", 0, EnvDTE.dbgHitCountType.dbgHitCountTypeNone);
    string strCondition = debugger.Breakpoints.Item(1).Condition;
    string strConditionType = debugger.Breakpoints.Item(1).ConditionType.ToString();
    owp.OutputString(strCondition + "\n" + strConditionType);
}
Shared Sub Condition(ByRef dte As EnvDTE.DTE)
    Dim strCondition As String
    Dim strType As String

    dte.Debugger.StepInto(True)
    dte.Debugger.Breakpoints.Add("", "Target001.cs", 15, 1, "tempC < tempF", _
                                 EnvDTE.dbgBreakpointConditionType.dbgBreakpointConditionTypeWhenTrue, _
                                 "C#", "", 0, "", 0, EnvDTE.dbgHitCountType.dbgHitCountTypeNone)
    strCondition = dte.Debugger.Breakpoints.Item(1).Condition.ToString()
    strType = dte.Debugger.Breakpoints.Item(1).ConditionType.ToString()
    MessageBox.Show("Condition Property Test: " + vbCrLf + _
                    strCondition + vbCrLf + strType)
End Sub

.NET Framework 安全性

请参阅

参考

Breakpoint 接口

EnvDTE 命名空间

其他资源

<PAVEOVER> 如何:指定断点条件

<PAVEOVER> 如何:指定命中次数