Propriedade VSProject2.WebReferencesFolder

Obtém o ProjectItem objeto representando a pasta de referências da Web do projeto. Se a pasta não existir, essa propriedade retornará Nothing (um nulluma referência nula (Nothing no Visual Basic) referência).

Namespace:  VSLangProj80
Assembly:  VSLangProj80 (em VSLangProj80.dll)

Sintaxe

'Declaração
ReadOnly Property WebReferencesFolder As ProjectItem
    Get
ProjectItem WebReferencesFolder { get; }
property ProjectItem^ WebReferencesFolder {
    ProjectItem^ get ();
}
abstract WebReferencesFolder : ProjectItem
function get WebReferencesFolder () : ProjectItem

Valor de propriedade

Tipo: EnvDTE.ProjectItem
A ProjectItem objeto representando a pasta de referências da Web.

Implementações

VSProject.WebReferencesFolder

Comentários

Referências de Web do projeto poderão ser recuperadas, acessando o ProjectItems propriedade da WebReferencesFolder.

Um projeto contém no máximo uma pasta de referências da Web. A pasta pode ser criada usando o CreateWebReferencesFolder método. Além disso, a pasta é criada automaticamente quando a primeira referência da Web é adicionada ao projeto, usando o CreateWebReferencesFolder método.

Em um Visual Basic ou Visual C# projeto, o Kind propriedade da WebReferencesFolder item de projeto é sempre vsProjectItemKindPhysicalFolder porque Visual Basic e Visual C# projetos aceitam somente físico arquivos.

Exemplos

Este exemplo cria uma pasta de referências da Web, se ainda não existir por um e exibe algumas das propriedades da pasta em uma caixa de mensagem. Para executar este exemplo como um suplemento, consulte Como: compilar e Executar a automação de exemplos de Código do modelo de objeto. Abrir um Visual Basic ou Visual C# o projeto antes de executar este exemplo.

[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."); 
}

Segurança do .NET Framework

Consulte também

Referência

VSProject2 Interface

Sobrecargas WebReferencesFolder

Namespace VSLangProj80