VSProjectEvents2.ReferencesEvents 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取一个 ReferencesEvents 对象,它提供对 References 集合的事件的访问。
public:
property VSLangProj::ReferencesEvents ^ ReferencesEvents { VSLangProj::ReferencesEvents ^ get(); };
public:
property VSLangProj::ReferencesEvents ^ ReferencesEvents { VSLangProj::ReferencesEvents ^ get(); };
[System.Runtime.InteropServices.DispId(1)]
public VSLangProj.ReferencesEvents ReferencesEvents { [System.Runtime.InteropServices.DispId(1)] get; }
[<System.Runtime.InteropServices.DispId(1)>]
[<get: System.Runtime.InteropServices.DispId(1)>]
member this.ReferencesEvents : VSLangProj.ReferencesEvents
Public ReadOnly Property ReferencesEvents As ReferencesEvents
属性值
返回一个 ReferencesEvents 对象。
实现
- 属性
示例
此示例通过使用属性连接特定项目的事件处理方法 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
注解
ReferencesEvents属性提供对三个事件的访问: ReferenceAdded 、 ReferenceChanged 和 ReferenceRemoved 。