次の方法で共有


VSWebSiteEvents インターフェイス

更新 : 2007 年 11 月

Web サイト プロジェクト内のイベント コレクションへのアクセスを提供します。

名前空間 :  VsWebSite
アセンブリ :  VsWebSite.Interop (VsWebSite.Interop.dll 内)

構文

'宣言
<GuidAttribute("9F1B1C2C-FA11-44AB-A7DA-926FF1927C70")> _
Public Interface VSWebSiteEvents
'使用
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

解説

このインターフェイスにアクセスするには、VSWebSite オブジェクトの VSWebSiteEvents プロパティを使用します。このオブジェクトは、現在の Visual Studio プロジェクトへの参照を使用してのみ取得できます。次にその例を示します。

Dim ws As VsWebSite.VSWebSite = DTE.Solution.Projects.Item(1).Object
ms778695.alert_note(ja-jp,VS.90).gifメモ :

このクラスで提供される機能は、Visual Studio 2005 以降のバージョンの Visual Studio で使用できます。Visual Web Developer Express Edition では使用できません。

次のサンプル マクロ モジュールは、VSWebSite イベントをサブスクライブする方法を示しています。このモジュールを使用するには、Visual Studio で Web サイト プロジェクトを開き、[ツール] メニューからマクロの IDE を開きます。新しいモジュールを作成し、そのモジュールにサンプル コードを貼り付けます。

さらに、このモジュールに、VsWebSite.Interop アセンブリへの参照を追加する必要があります。InitEvents() メソッド内にカーソルを置き、F5 キーを押すと、イベント サブスクリプションが初期化されます。各イベントをテストするには、Web サイト プロジェクト内で、指定されたアクションを実行してください。詳細については、「方法 : マクロでイベントを処理する」を参照してください。

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

参照

参照

VSWebSiteEvents メンバ

VsWebSite 名前空間

DTE

VsWebSite

AssemblyReferencesEvents

WebReferencesEvents

WebServicesEvents

WebSiteMiscEvents

その他の技術情報

オートメーションと機能拡張のリファレンス

オートメーション アセンブリおよび DTE2 オブジェクトの参照

Visual Studio マクロ

アドインおよびウィザードの作成

方法 : マクロでイベントを処理する