Condividi tramite


Interfaccia VSWebSiteEvents

Fornisce l'accesso agli insiemi di eventi del progetto di sito Web.

Spazio dei nomi:  VsWebSite
Assembly:  VsWebSite.Interop (in VsWebSite.Interop.dll)

Sintassi

'Dichiarazione
<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

Il tipo VSWebSiteEvents espone i seguenti membri.

Proprietà

  Nome Descrizione
Proprietà pubblica AssemblyReferencesEvents Ottiene un riferimento agli eventi per la proprietà dell'insieme References in un progetto di sito Web.
Proprietà pubblica WebReferencesEvents Ottiene un riferimento agli eventi per la proprietà dell'insieme WebReferences in un progetto di sito Web.
Proprietà pubblica WebServicesEvents Ottiene un riferimento agli eventi per la proprietà dell'insieme WebServices in un progetto di sito Web.
Proprietà pubblica WebSiteMiscEvents Ottiene un riferimento a eventi vari in un progetto di sito Web.

In alto

Note

A questa interfaccia si accede con la proprietà VSWebSiteEvents di un oggetto VSWebSite che è possibile ottenere solo tramite un riferimento al progetto di Visual Studio corrente come illustrato nell'esempio seguente:

Dim ws As VsWebSite.VSWebSite = DTE.Solution.Projects.Item(1).Object

Nota

Le funzionalità fornite da questa classe sono disponibili a partire da Visual Studio 2005. Non è disponibile in Visual Web Developer Express Edition.

Esempi

Il modulo macro di esempio seguente illustra come sottoscrivere gli eventi VSWebSite. Per utilizzare il modulo, aprire un progetto di sito Web in Visual Studio e aprire l'IDE macro dal menu Strumenti. Creare un nuovo modulo e incollare il codice di esempio nel modulo.

È inoltre necessario aggiungere un riferimento all'assembly VsWebSite.Interop nel modulo. Inizializzare la sottoscrizione degli eventi posizionando il cursore nel metodo InitEvents() e premendo F5. Per testare ogni evento, eseguire l'azione specificata nel progetto di sito Web. Per ulteriori informazioni, vedere Procedura: gestire gli eventi in una 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

Vedere anche

Riferimenti

Spazio dei nomi VsWebSite

DTE

VsWebSite

AssemblyReferencesEvents

WebReferencesEvents

WebServicesEvents

WebSiteMiscEvents

Altre risorse

Riferimenti su Extensibility e automazione

Riferimenti agli assembly di automazione e all'oggetto DTE2

Visual Studio Macro

Creazione di componenti aggiuntivi e di procedure guidate

Procedura: gestire gli eventi in una macro