VSProjectEvents.BuildManagerEvents 属性

获取提供对 BuildManager 事件的访问的 BuildManagerEvents 对象。

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

语法

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

属性值

类型:VSLangProj.BuildManagerEvents
返回 BuildManagerEvents 对象。

备注

BuildManager 事件用于跟踪对与自定义工具关联的项目项的更改。DesignTimeOutputDirty 指示已添加或更改项目项。DesignTimeOutputDeleted 指示已删除项目项。有关更多信息,请参见 BuildManager

示例

此示例使用 Events 对象将事件处理方法连接到特定项目的 DesignTimeOutputDeletedDesignTimeOutputDirty

' Macro Editor
' Connects events in a Visual Basic or Visual C# project.
Imports VSLangProj
Sub ConnectEvents()
   Dim proj As Project = DTE.Solution.Projects.Item(1)
   Dim vsproj As VSProject = CType(proj.Object, VSProject)
   Dim buildman As BuildManagerEvents = vsproj.Events.BuildManagerEvents
   AddHandler buildman.DesignTimeOutputDeleted, AddressOf OutputDeleted
   AddHandler buildman.DesignTimeOutputDirty, AddressOf OutputDirty
End Sub

Sub OutputDeleted(ByVal moniker As String)
   MsgBox("Output " & moniker & " was deleted.")
End Sub

Sub OutputDirty(ByVal moniker As String)
   MsgBox("Output " & moniker & " is dirty.")
End Sub

下面两个示例使用后期绑定的 VBBuildManagerEvents 属性连接到 Visual Basic 项目事件。使用 CSharpBuildManagerEvents 属性连接到 Visual C# 事件。

还有两种处理 BuildManager 对象事件的后期绑定方法。第一种方法允许处理特定项目的事件,需要编译 Option Strict Off 语句。VBImportsEvents 的参数是可选的。如果省略,则将收到解决方案中所有 Visual Basic 项目的事件。如果 VBBuildManagerEvents 调用的参数不是 Project 类型,此方法将返回一个错误。

' Macro editor
Option Strict Off
Imports VSLangProj
Dim WithEvents buildEvents As BuildManagerEvents
Sub ConnectProjectBuildManagerEvents()
   Dim proj As Project = DTE.Solution.Projects.Item(1)
   buildEvents = DTE.Events.VBBuildManagerEvents(proj)
End Sub

Public Sub buildEvents_DesignTimeOutputDeleted(ByVal bstrOutputMoniker _
As String) Handles buildEvents.DesignTimeOutputDeleted
   MsgBox(bstrOutputMoniker)
End Sub

第二种后期绑定方法使您可以响应解决方案中所有项目的事件。该方法没有提供只为特定项目筛选事件的方法。它将用 Option Strict On 编译。

' Macro editor
Imports VSLangProj
Dim WithEvents buildEvents As VSLangProj.BuildManagerEvents
Sub ConnectAllBuildManagerEvents()
   buildEvents = CType(DTE.Events.GetObject("VBBuildManagerEvents"), _
      BuildManagerEvents)
End Sub

Public Sub buildEvents_DesignTimeOutputDeleted(ByVal bstrOutputMoniker _
As String) Handles buildEvents.DesignTimeOutputDeleted
   MsgBox(bstrOutputMoniker)
End Sub

.NET Framework 安全性

请参见

参考

VSProjectEvents 接口

VSLangProj 命名空间