VSWebSiteEvents 接口
提供对网站项目中的事件集合的访问。
命名空间: VsWebSite
程序集: VsWebSite.Interop(在 VsWebSite.Interop.dll 中)
语法
声明
<GuidAttribute("9F1B1C2C-FA11-44AB-A7DA-926FF1927C70")> _
Public Interface VSWebSiteEvents
[GuidAttribute("9F1B1C2C-FA11-44AB-A7DA-926FF1927C70")]
public interface VSWebSiteEvents
[GuidAttribute(L"9F1B1C2C-FA11-44AB-A7DA-926FF1927C70")]
public interface class VSWebSiteEvents
[<GuidAttribute("9F1B1C2C-FA11-44AB-A7DA-926FF1927C70")>]
type VSWebSiteEvents = interface end
public interface VSWebSiteEvents
VSWebSiteEvents 类型公开以下成员。
属性
名称 | 说明 | |
---|---|---|
AssemblyReferencesEvents | 获取对某个网站项目中 References 集合属性的事件的引用。 | |
WebReferencesEvents | 获取对某个网站项目中 WebReferences 集合属性的事件的引用。 | |
WebServicesEvents | 获取对某个网站项目中 WebServices 集合属性的事件的引用。 | |
WebSiteMiscEvents | 获取对网站项目中杂项事件的引用。 |
页首
备注
通过 VSWebSite 对象的 VSWebSiteEvents 属性访问此接口,该对象仅能通过对当前 Visual Studio 项目的引用获得,如下例所示:
Dim ws As VsWebSite.VSWebSite = DTE.Solution.Projects.Item(1).Object
提示
此类提供的功能在从 Visual Studio 2005 起的各个 Visual Studio 版本中均可用。 它在 Visual Web Developer 速成版中不可用。
示例
下面的示例宏模块演示了如何订阅 VSWebSite 事件。 若要使用此模块,请在 Visual Studio 中打开一个网站项目,然后从**“工具”**菜单上打开宏 IDE。 创建一个新的模块并将此示例代码粘贴到该模块中。
同时您还必须将对 VsWebSite.Interop 程序集的引用添加到模块中。 将光标放在 InitEvents() 方法中并按 F5 来初始化事件订阅。 若要测试每个事件,请在您的网站项目中执行指定的操作。 有关更多信息,请参见如何:使用宏处理事件
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports VsWebSite
Imports System.Diagnostics
Public Module VsWS_Events
' Initialize the VsWebSite and the Events
Sub InitAssemblyRefsEvents()
' Get a reference to the first Web site
' in the current solution
Dim ws As VsWebSite.VSWebSite = _
DTE.Solution.Projects.Item(1).Object
' Attach the Web site events to module events
AssemblyRefsEvents = _
ws.VSWebSiteEvents.AssemblyReferencesEvents
End Sub
' Declare the event
' The macro IDE requires the attribute
' in order to trap the events
<System.ContextStaticAttribute()> _
Public WithEvents AssemblyRefsEvents As _
VsWebSite.AssemblyReferencesEvents
<System.ContextStaticAttribute()> _
Public WithEvents MiscEvents As _
VsWebSite.WebSiteMiscEvents
<System.ContextStaticAttribute()> _
Public WithEvents WebRefsEvents As _
VsWebSite.WebReferencesEvents
<System.ContextStaticAttribute()> _
Public WithEvents WebSvcsEvents As _
VsWebSite.WebServicesEvents
' Handler for the AssemblyReferenceAdded event
' Test: Add an Assembly Reference to your Web site project
Private Sub AssemblyRefAdded _
(ByVal ref As VsWebSite.AssemblyReference) _
Handles AssemblyRefsEvents.AssemblyReferenceAdded
' Display the name of the added reference
MsgBox("Assembly Added: " & ref.Name)
End Sub
' Handler for the After Refresh Folder event
' Test: Refresh a folder in your Web site project
Private Sub AfterRefresh _
(ByVal ref As Object) _
Handles MiscEvents.OnAfterFolderRefresh
' Display the folder as text
MsgBox("Folder Refreshed: " & ref.ToString())
End Sub
' Handler for the Web Reference Added event
' Test: Add a Web Reference to your Web site project
Private Sub WebRefAdded _
(ByVal ref As VsWebSite.WebReference) _
Handles WebRefsEvents.WebReferenceAdded
' Display the name of the added reference
MsgBox("Web Reference Added: " & ref.Name)
End Sub
' Handler for the Web Service Added event
' Test: Add a Web service to your Web site project
Private Sub WebSvcAdded _
(ByVal ref As VsWebSite.WebService) _
Handles WebSvcsEvents.WebServiceAdded
' Display the name of the added item
MsgBox("Web Service Added: " & ref.Name)
End Sub
End Module
请参见
参考
VsWebSite