Aracılığıyla paylaş


VSWebSite Arabirim

Özellikler ve bir Web sitesi projesi için yöntemler sağlar.

Ad alanı:  VsWebSite
Derleme:  VsWebSite.Interop (VsWebSite.Interop.dll içinde)

Sözdizimi

'Bildirim
<GuidAttribute("70758CA4-91F8-46AD-80A7-73BC21BAE68B")> _
Public Interface VSWebSite
[GuidAttribute("70758CA4-91F8-46AD-80A7-73BC21BAE68B")]
public interface VSWebSite
[GuidAttribute(L"70758CA4-91F8-46AD-80A7-73BC21BAE68B")]
public interface class VSWebSite
[<GuidAttribute("70758CA4-91F8-46AD-80A7-73BC21BAE68B")>]
type VSWebSite =  interface end
public interface VSWebSite

VSWebSite türü aşağıdaki üyeleri ortaya koyar.

Özellikler

  Ad Açıklama
Genel özellik CodeFolders Web sitesindeki kod klasörler olarak yapılandırılmış olan klasörler topluluğu alır.
Genel özellik DTE Başvuruyu alır DTE2 nesne içeren bu Web sitesi projesi.
Genel özellik Project Bu Web sitesi olarak başvuruyu alır bir Project nesne.
Genel özellik References Alır bir AssemblyReferences nesnesini içeren derlemeler ve projeler için geçerli bir Web sitesi.
Genel özellik TemplatePath Web sitesi öğeleri için şablonlar içeren klasörün adını ve tam yolunu alır.
Genel özellik URL Web sitesi açmak için kullanılan URL'sini alır.
Genel özellik UserTemplatePath Yeni proje öğeler için Kullanıcı şablonları klasörüne yolu alır.
Genel özellik VSWebSiteEvents Alır VSWebSiteEvents Web sitesi ekleme kullanılabilir olduğu için nesneolay işleyicileri.
Genel özellik WebReferences Alır bir WebReferences nesnesini içeren başvurular Web hizmetlerine harcanan göre Web sitesi.
Genel özellik WebServices Alır bir WebServices nesnesini içeren Web Hizmetleri tarafından sergilenen topluluğubu Web sitesine.

Üst

Yöntemler

  Ad Açıklama
Genel yöntem AddFromTemplate Yeni bir oluşturur ProjectItem Web sitesi projesi.
Genel yöntem EnsureServerRunning asp başlar.net Development Server, gerekirse ve Web sitesinin URL'sini döndürür.
Genel yöntem GetUniqueFilename Belirtilen kök adı ve dosya adı uzantısı kullanarak belirtilen klasör içinde benzersiz bir dosya adı verir.
Genel yöntem PreCompileWeb Web sitesi derler ve derlenmiş çıktıyı belirtilen dosyaya yazar.
Genel yöntem Refresh Hesap dışında Visual Studio Web sitesine yaptığınız değişiklikler için görüntüye yeniler.
Genel yöntem WaitUntilReady Arka plan işlemleri yürütmeden bitinceye kadar tüm yöntem çağrıları engeller.

Üst

Açıklamalar

Use VSWebSite bir Web sitesi projesi ya da bir makroyu veya eklentiyi Visual Studio işlemek için arabirim

Özellikleri ve yöntemleri bu sınıftaki yanı sıra vardır daha fazla özellik kullanılabilir kullanarak Web sitesi projeleri için WebSiteProperties sınıfa

Not

Bu sınıf tarafından sağlanan işlevselliği, Visual Studio 2005 ile başlayan Visual Studio sürümlerinde kullanılabilir. Visual Web Developer Express Edition'da kullanılamaz.

Örnekler

Aşağıdaki örnek, bir eklenti, Visual Studio Web sitesi projesi ile etkileşim kurmak için nasıl kullanılacağını gösterir. Eklenti ya da başvuru sırasında derleme için olay günlüğüne yazmak için olay işleyicilerini kullanır veya Web hizmeti için Web Başvurusu projeye eklenir. Çözüm kapalı olduğunda buna ek olarak, bunu her Web sitesi Proje Özeti bir metin dosyasına yazar.

Örneği çalıştırmak için kullanmak Nasıl Yapılır: oluşturmak bir Ekle bir eklenti projesi oluşturma ve değiştirme kod dosyasında elde edilen Connect.cs örnek kod. VsWebSite.Interop derleme başvurusu oluşturmak gerekecektir.

[C#]

using System;
using System.IO;
using System.Collections;
using System.Diagnostics;
using Extensibility;
using EnvDTE;
using EnvDTE80;
using VsWebSite;

// The object for implementing an Add-in.
public class Connect : IDTExtensibility2
{
    private DTE2 _applicationObject;
    private AddIn _addInInstance;

    // Implements the constructor for the Add-in object.
    // Created by the Add-In Wizard
    public Connect()
    {
    }

    // Event method created by the Add-In Wizard.
    // Occurs when the Add-In connects with the application.
    public void OnConnection(object application, ext_ConnectMode 
        connectMode, object addInInst, ref Array custom)
    {
        _applicationObject = (DTE2)application;
        _addInInstance = (AddIn)addInInst;

        // Attach Solution event handlers
        _applicationObject.DTE.Events.SolutionEvents.Opened 
            += new _dispSolutionEvents_OpenedEventHandler
                (SolutionEvents_Opened);
        _applicationObject.DTE.Events.SolutionEvents.QueryCloseSolution 
            += new _dispSolutionEvents_QueryCloseSolutionEventHandler
                (SolutionEvents_QueryCloseSolution);
    }

    // Custom event method that occurs before a solution is closed.
    private void SolutionEvents_QueryCloseSolution(ref bool fCancel)
    {
        foreach (Project proj in _applicationObject.Solution.Projects)
        {
            // Make sure background compilation is finished
            ((VSWebSite)proj.Object).WaitUntilReady();

            System.Text.StringBuilder strBldr = 
                new System.Text.StringBuilder();

            strBldr.AppendLine("Summary for Web Site: " 
                + ((VSWebSite)proj.Object).URL);
            strBldr.AppendLine("Solution: " 
                + _applicationObject.Solution.FullName);
            strBldr.AppendLine("Web References:");
            foreach (WebReference wref in 
                ((VSWebSite)proj.Object).WebReferences)
                strBldr.AppendLine("    " + wref.Namespace);
            strBldr.AppendLine("Assembly References:");
            foreach (AssemblyReference aref in 
                ((VSWebSite)proj.Object).References)
                strBldr.AppendLine("    " + aref.Name);
            // list the files?

            ((VSWebSite)proj.Object).VSWebSiteEvents.WebReferencesEvents.WebReferenceAdded
                -= WebRefEvents_WebRefAdded;

            string strBody = strBldr.ToString();

            // Save the summary as a text file in the Web site.
            string fName = _applicationObject.FullName;
            fName = fName.Substring(0, fName.Length - 4);
            fName += "." + ((VSWebSite)proj.Object).GetUniqueFilename
                ("/", "ProjectSummary", ".txt");
            if (File.Exists(fName))
                File.Delete(fName);
            StreamWriter sw = File.CreateText(fName);
            sw.Write(strBody);
            sw.Close();
        }
    }

    // Custom event method that occurs when a solution is opened.
    private void SolutionEvents_Opened()
    {
        // When solution is opened, attach event handlers for projects
        foreach (Project proj in _applicationObject.Solution.Projects)
        {   // Only attach event handlers if it is a Web site
            if (proj.Object is VSWebSite)
            {
                ((VSWebSite)proj.Object).VSWebSiteEvents.WebReferencesEvents.WebReferenceAdded +=
                    new _dispWebReferencesEvents_WebReferenceAddedEventHandler
                    (WebRefEvents_WebRefAdded);
                ((VSWebSite)proj.Object).VSWebSiteEvents.AssemblyReferencesEvents.AssemblyReferenceAdded += 
                    new _dispAssemblyReferencesEvents_AssemblyReferenceAddedEventHandler
                    (AssemblyRefsEvents_AssemblyRefAdded);
            }
        }
    }

    // Custom event method that occurs when a Reference is added.
    private void AssemblyRefsEvents_AssemblyRefAdded(AssemblyReference AssemblyRef)
    {
        EventLog appLog = new EventLog();
        appLog.Source = "VSWSTest." + AssemblyRef.ContainingProject.Name;
        appLog.WriteEntry("AssemblyReference added: " + AssemblyRef.Name);
    }
    
    // Custom event method that occurs when a Web Reference is added.
    private void WebRefEvents_WebRefAdded(WebReference webRef)
    {
        EventLog appLog = new EventLog();
        appLog.Source = "VSWSTest." + webRef.ContainingProject.Name;
        appLog.WriteEntry("WebReference added: " + webRef.Namespace);
    }

    #region Required but unused event handlers

    /// <summary>Implements the OnDisconnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being unloaded.</summary>
    /// <param term='disconnectMode'>Describes how the Add-in is being unloaded.</param>
    /// <param term='custom'>Array of parameters that are host application specific.</param>
    /// <seealso class='IDTExtensibility2' />
    public void OnDisconnection(ext_DisconnectMode disconnectMode, ref Array custom)
    {
    }

    /// <summary>Implements the OnAddInsUpdate method of the IDTExtensibility2 interface. Receives notification when the collection of Add-ins has changed.</summary>
    /// <param term='custom'>Array of parameters that are host application specific.</param>
    /// <seealso class='IDTExtensibility2' />
    public void OnAddInsUpdate(ref Array custom)
    {
    }

    /// <summary>Implements the OnStartupComplete method of the IDTExtensibility2 interface. Receives notification that the host application has completed loading.</summary>
    /// <param term='custom'>Array of parameters that are host application specific.</param>
    /// <seealso class='IDTExtensibility2' />
    public void OnStartupComplete(ref Array custom)
    {
    }

    /// <summary>Implements the OnBeginShutdown method of the IDTExtensibility2 interface. Receives notification that the host application is being unloaded.</summary>
    /// <param term='custom'>Array of parameters that are host application specific.</param>
    /// <seealso class='IDTExtensibility2' />
    public void OnBeginShutdown(ref Array custom)
    {
    }

    #endregion
}

Ayrıca bkz.

Başvuru

VsWebSite Ad Alanı

EnvDTE

WebSiteProperties

Diğer Kaynaklar

Otomasyon ve genişletilebilirlik Başvuru

Başvuru Otomasyon derlemeler ve DTE2 nesne

Visual Studio Makrolar

Oluşturma Ekle-bileşenleri ve Sihirbazlar