VSProjectEvents.ReferencesEvents 屬性
取得可用來存取 References 集合事件的 ReferencesEvents 物件。
命名空間: VSLangProj
組件: VSLangProj (在 VSLangProj.dll 中)
語法
'宣告
ReadOnly Property ReferencesEvents As ReferencesEvents
ReferencesEvents ReferencesEvents { get; }
property ReferencesEvents^ ReferencesEvents {
ReferencesEvents^ get ();
}
abstract ReferencesEvents : ReferencesEvents with get
function get ReferencesEvents () : ReferencesEvents
屬性值
類型:VSLangProj.ReferencesEvents
傳回 ReferencesEvents 物件。
備註
ReferencesEvents 屬性可用來存取三個事件:ReferenceAdded、ReferenceChanged 和 ReferenceRemoved。
範例
這個範例使用 ReferencesEvents 屬性將事件處理方法連接到特定專案。
' Macro Editor
' Connects trivial methods to the ReferenceAdded and ReferenceDeleted
' events of the first project in the solution.
Imports VSLangProj
Sub ConnectEvents()
Dim proj As Project = DTE.Solution.Projects.Item(1)
Dim vsproj As VSProject = CType(proj.Object, VSProject)
Dim refEvents As ReferencesEvents = vsproj.Events.ReferencesEvents
AddHandler refEvents.ReferenceAdded, AddressOf ReferenceAdded
AddHandler refEvents.ReferenceRemoved, AddressOf ReferenceRemoved
AddHandler refEvents.ReferenceChanged, AddressOf ReferenceChanged
End Sub
Sub ReferenceRemoved(ByVal removedRef As Reference)
MsgBox("The reference for " & removedRef.Name & " was removed.")
End Sub
Sub ReferenceChanged(ByVal removedRef As Reference)
MsgBox("The reference for " & removedRef.Name & " was changed.")
End Sub
Sub ReferenceAdded(ByVal addedRef As Reference)
MsgBox("The reference for " & addedRef.Name & " was added.")
End Sub
.NET Framework 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。