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 Express 版中使用。 |
範例
下列巨集模組範例將說明如何訂閱 VSWebSite 事件。若要使用這個模組,請在 Visual Studio 中開啟網站專案,然後從 [工具] 功能表,開啟巨集 IDE。您可以建立新模組,並將範例程式碼貼入此模組。
此外,您還必須將 VsWebSite.Interop 組件 (Assembly) 的參考加入至模組。您可以將資料指標放置在 InitEvents() 方法中並按下 F5,以初始化事件訂閱。若要測試每個事件,請執行網站專案中指定的動作。如需詳細資訊,請參閱HOW TO:處理巨集中的事件。
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