VSProjectEvents2.ReferencesEvents 属性
获取一个 ReferencesEvents 对象,它提供对 References 集合的事件的访问。
命名空间: VSLangProj80
程序集: VSLangProj80(在 VSLangProj80.dll 中)
语法
声明
ReadOnly Property ReferencesEvents As ReferencesEvents
ReferencesEvents ReferencesEvents { get; }
property ReferencesEvents^ ReferencesEvents {
ReferencesEvents^ get ();
}
abstract ReferencesEvents : ReferencesEvents with get
function get ReferencesEvents () : ReferencesEvents
属性值
类型:ReferencesEvents
返回 ReferencesEvents 对象。
备注
ReferencesEvents 属性提供对 ReferenceAdded、ReferenceChanged 和 ReferenceRemoved 这三个事件的访问。
示例
此示例通过使用 ReferencesEvents 属性为特定项目连接事件处理方法。 有关如何运行宏示例的更多信息,请参见 如何:编译和运行自动化对象模型代码示例。
在运行此宏之前打开 Visual Basic 或 Visual C# 项目。
' Macro Editor
' Connects trivial methods to the ReferenceAdded and ReferenceDeleted
' events of the first project in the solution.
Imports VSLangProj
Imports VSLangProj80
Sub ConnectEvents()
Dim proj As Project = DTE.Solution.Projects.Item(1)
Dim vsproj As VSProject2 = CType(proj.Object, VSProject2)
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 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关详细信息,请参阅通过部分受信任的代码使用库。