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 属性提供对 ReferenceAddedReferenceChangedReferenceRemoved 这三个事件的访问。

示例

此示例使用 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 安全性

请参见

参考

VSProjectEvents 接口

VSLangProj 命名空间