VSProjectEvents.ReferencesEvents 属性
获取一个 ReferencesEvents 对象,它提供对 References 集合的事件的访问。
命名空间: VSLangProj
程序集: VSLangProj(在 VSLangProj.dll 中)
语法
声明
ReadOnly Property ReferencesEvents As ReferencesEvents
ReferencesEvents ReferencesEvents { get; }
property ReferencesEvents^ ReferencesEvents {
ReferencesEvents^ get ();
}
abstract ReferencesEvents : ReferencesEvents
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 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。