Share via


VSProject2.WebReferencesFolder (Propiedad)

Obtiene el objeto ProjectItem que representa la carpeta Referencias web del proyecto. Si la carpeta no existe, esta propiedad devuelve Nothing (una referencia nullreferencia null (Nothing en Visual Basic)).

Espacio de nombres:  VSLangProj80
Ensamblado:  VSLangProj80 (en VSLangProj80.dll)

Sintaxis

'Declaración
ReadOnly Property WebReferencesFolder As ProjectItem
ProjectItem WebReferencesFolder { get; }
property ProjectItem^ WebReferencesFolder {
    ProjectItem^ get ();
}
abstract WebReferencesFolder : ProjectItem with get
function get WebReferencesFolder () : ProjectItem

Valor de propiedad

Tipo: ProjectItem
Objeto ProjectItem que representa la carpeta Referencias web.

Comentarios

Pueden recuperarse las referencias Web de un proyecto obteniendo acceso a la propiedad ProjectItems de WebReferencesFolder.

Un proyecto contiene siempre al menos una carpeta Web References. Esta carpeta se puede crear utilizando el método CreateWebReferencesFolder. Además, la carpeta se crea de forma automática cuando se agrega la primera referencia Web al proyecto utilizando el método CreateWebReferencesFolder.

En un proyecto Visual Basic o Visual C#, la propiedad Kind del elemento de proyecto WebReferencesFolder siempre es vsProjectItemKindPhysicalFolder porque los proyectos de Visual Basic y Visual C# solo admiten archivos físicos.

Ejemplos

En este ejemplo se crea una carpeta Referencias Web si no existe una todavía, y se muestran algunas de las propiedades de la carpeta en un cuadro de mensaje. Para ejecutar este ejemplo como complemento, vea Cómo: Compilar y ejecutar los ejemplos de código del modelo de objetos de automatización. Abra un proyecto de Visual Basic o Visual C# antes de ejecutar este ejemplo.

[Visual Basic]

' Add-in code.
' This example creates a Web references folder, if it does not 
' already exist, and displays some of the folder properties.
Imports VSLangProj
Imports VSLangProj80
Public Sub OnConnection(ByVal application As Object _
, ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, _
 ByRef custom As Array) Implements IDTExtensibility2.OnConnection
    applicationObject = CType(application, DTE2)
    addInInstance = CType(addInInst, AddIn)
    WebReferencesFolderExample(applicationObject)
End Sub

Sub WebReferencesFolderExample(ByVal dte As DTE2)
    ' This example assumes that the first project in the 
    ' solution is a Visual Basic or C# project.
    Dim aVSProject As VSProject2 = _
    CType(applicationObject.Solution.Projects.Item(1)._
    Object, VSProject2)

    ' Add a new folder if it does not already exist.
    If (aVSProject.WebReferencesFolder Is Nothing) Then
        Dim newFolder As ProjectItem
        newFolder = aVSProject.CreateWebReferencesFolder()
    End If

    ' Display the name of the Web references folder.
    Dim theFolder As ProjectItem = aVSProject.WebReferencesFolder
    MsgBox("The name of the WebReferences folder is " _
    & theFolder.Name & ".")

    ' All Visual Basic and C# Web references folders are physical.
    If (theFolder.Kind = _
    EnvDTE.Constants.vsProjectItemKindPhysicalFolder) Then
        MsgBox(theFolder.Name & " is a physical folder.")
    End If

    MsgBox("There are " & theFolder.ProjectItems.Count.ToString() & _
    " Web references.")
End Sub

[C#]

using System.Windows.Forms;
using VSLangProj;
using VSLangProj2;
using VSLangProj80;

public void OnConnection(object application, ext_ConnectMode
 connectMode, object addInInst, ref Array custom)
{
    applicationObject = (DTE2)application;
    addInInstance = (AddIn)addInInst;
    WebReferencesFolderExample((DTE2)applicationObject);
}

public void WebReferencesFolderExample( DTE2 dte ) 
{ 
    // This example assumes that the first project in the 
    // solution is a Visual Basic or C# project.
    VSProject2 aVSProject = ( ( VSProject2 )
(applicationObject.Solution.Projects.Item( 1 ).Object ) ); 
    // Add a new folder if it does not already exist.
    if ( ( aVSProject.WebReferencesFolder == null ) ) 
    { 
        ProjectItem newFolder = null; 
        newFolder = aVSProject.CreateWebReferencesFolder(); 
    } 
    // Display the name of the Web references folder.
    ProjectItem theFolder = aVSProject.WebReferencesFolder; 
    MessageBox.Show( "The name of the WebReferences folder is " 
+ theFolder.Name + "."); 
    // All Visual Basic and C# Web references folders are physical.
    if ( ( theFolder.Kind == 
EnvDTE.Constants.vsProjectItemKindPhysicalFolder ) ) 
    { 
        MessageBox.Show( theFolder.Name + " is a physical folder."); 
    } 
    MessageBox.Show( "There are " +
 theFolder.ProjectItems.Count.ToString() + " Web references."); 
}

Seguridad de .NET Framework

Vea también

Referencia

VSProject2 Interfaz

VSLangProj80 (Espacio de nombres)