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