VSProjectEvents.BuildManagerEvents 屬性
取得可用來存取 BuildManager 事件的 BuildManagerEvents 物件。
命名空間: VSLangProj
組件: VSLangProj (在 vslangproj.dll 中)
語法
'宣告
ReadOnly Property BuildManagerEvents As BuildManagerEvents
'用途
Dim instance As VSProjectEvents
Dim value As BuildManagerEvents
value = instance.BuildManagerEvents
BuildManagerEvents BuildManagerEvents { get; }
property BuildManagerEvents^ BuildManagerEvents {
BuildManagerEvents^ get ();
}
/** @property */
BuildManagerEvents get_BuildManagerEvents ()
function get BuildManagerEvents () : BuildManagerEvents
屬性值
傳回 BuildManagerEvents 物件。
備註
BuildManager 事件是用來追蹤與自訂工具相關的專案項目的變更。DesignTimeOutputDirty 事件表示有專案項目被加入或更改,DesignTimeOutputDeleted 事件則表示有專案項目被刪除。如需詳細資訊,請參閱 BuildManager。
範例
此範例用 Events 物件將事件處理方法連結到某特定專案的 DesignTimeOutputDeleted 和 DesignTimeOutputDirty 方法。
' 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 專案事件。若要連接 Visual C# 事件,請用 CSharpBuildManagerEvents 屬性。
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