VSWebSiteEvents Interface
Provides access to events collections in the Web site project.
Namespace: VsWebSite
Assembly: VsWebSite.Interop (in VsWebSite.Interop.dll)
Syntax
'Declaration
<GuidAttribute("9F1B1C2C-FA11-44AB-A7DA-926FF1927C70")> _
Public Interface VSWebSiteEvents
'Usage
Dim instance As VSWebSiteEvents
[GuidAttribute("9F1B1C2C-FA11-44AB-A7DA-926FF1927C70")]
public interface VSWebSiteEvents
[GuidAttribute(L"9F1B1C2C-FA11-44AB-A7DA-926FF1927C70")]
public interface class VSWebSiteEvents
public interface VSWebSiteEvents
Remarks
This interface is accessed with the VSWebSiteEvents property of a VSWebSite object, which can be obtained only through a reference to the current Visual Studio project, as in the following example:
Dim ws As VsWebSite.VSWebSite = DTE.Solution.Projects.Item(1).Object
Note
The functionality provided by this class is available in versions of Visual Studio starting with Visual Studio 2005. It is not available in Visual Web Developer Express Edition.
Examples
The following sample macro module shows how to subscribe to VSWebSite events. To use the module, open a Web site project in Visual Studio, and from the Tools menu, open the macro IDE. Create a new module and paste the sample code into the module.
You must also add a reference to the VsWebSite.Interop assembly to the module. Initialize the event subscription by putting the cursor in the InitEvents() method and pressing F5. To test each event, carry out the specified action in your Web site project. For more information, see How to: Handle Events in a Macro
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
See Also
Reference
Other Resources
Automation and Extensibility Reference