VSProjectEvents2.VSLangProjWebReferencesEvents 属性
获取一个提供对 Web 引用事件的访问的 VSLangProjWebReferencesEvents 对象。
命名空间: VSLangProj80
程序集: VSLangProj80(在 VSLangProj80.dll 中)
语法
声明
ReadOnly Property VSLangProjWebReferencesEvents As VSLangProjWebReferencesEvents
VSLangProjWebReferencesEvents VSLangProjWebReferencesEvents { get; }
property VSLangProjWebReferencesEvents^ VSLangProjWebReferencesEvents {
VSLangProjWebReferencesEvents^ get ();
}
abstract VSLangProjWebReferencesEvents : VSLangProjWebReferencesEvents
function get VSLangProjWebReferencesEvents () : VSLangProjWebReferencesEvents
属性值
类型:VSLangProj80.VSLangProjWebReferencesEvents
VSLangProjWebReferencesEvents 对象。
示例
此示例通过使用 VSLangProjWebReferencesEvents 属性为特定项目连接事件处理方法。 有关如何运行宏示例的更多信息,请参见 如何:编译和运行自动化对象模型代码示例。
在运行此宏之前,请打开一个 Visual Basic、Visual C# 或 Visual J# 项目。
' Macro code.
' Connects trivial methods to the OnAfterWebReferenceAdded,
' OnBeforeWebReferenceRemoved, and OnWebReferenceChanged
' events of the first project in the solution.
' The first project is a Visual Basic, C#, or J# rpoject.
Imports VSLangProj
Imports VSLangProj80
Sub ConnectWebEvents()
Dim proj As Project = DTE.Solution.Projects.Item(1)
Dim vsproj As VSProject2 = CType(proj.Object, VSProject2)
Dim refEvents As VSLangProjWebReferencesEvents = _
vsproj.Events2.VSLangProjWebReferencesEvents
AddHandler refEvents.OnAfterWebReferenceAdded, _
AddressOf WebReferenceAdded
AddHandler refEvents.OnBeforeWebReferenceRemoved, _
AddressOf WebReferenceRemoved
AddHandler refEvents.OnWebReferenceChanged, _
AddressOf WebReferenceChanged
End Sub
Sub WebReferenceRemoved(ByVal removedRef As Object)
MsgBox("The reference for " & removedRef.Name & " was removed.")
End Sub
Sub WebReferenceChanged(ByVal changedRef As Object)
MsgBox("The reference for " & changedRef.Name & " was changed.")
End Sub
Sub WebReferenceAdded(ByVal addedRef As Object)
MsgBox("The reference for " & addedRef.Name & " was added.")
End Sub
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。