Share via


VSProject2.CreateWebReferencesFolder 메서드

프로젝트의 Web References 폴더를 만듭니다.

네임스페이스:  VSLangProj80
어셈블리:  VSLangProj80(VSLangProj80.dll)

구문

‘선언
Function CreateWebReferencesFolder As ProjectItem
ProjectItem CreateWebReferencesFolder()
ProjectItem^ CreateWebReferencesFolder()
abstract CreateWebReferencesFolder : unit -> ProjectItem
function CreateWebReferencesFolder() : ProjectItem

반환 값

형식: ProjectItem
ProjectItem 개체

설명

Web References 폴더가 이미 있으면 이 속성은 기존 폴더의 ProjectItem을 반환합니다.

예제

이 예제에서는 Web References 폴더를 만듭니다. 예제가 제대로 작동하려면 솔루션의 첫 번째 프로젝트가 Visual Basic 또는 Visual C# 프로젝트여야 합니다. 이 예제를 추가 기능으로 실행하려면 방법: 자동화 개체 모델 코드의 예제 컴파일 및 실행을 참조하십시오.

[Visual Basic]

' Add-in code.
Imports VSLangProj
Imports VSLangProj80
' This example creates a Web References folder, if it does not 
' already exist, and displays some properties of the folder.
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 webFolder As ProjectItem
        webFolder = 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 & ".")

    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 webFolder = null;
        webFolder = 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 + ".");

    if ((theFolder.Kind == 
EnvDTE.Constants.vsProjectItemKindPhysicalFolder))
    {
        MessageBox.Show(theFolder.Name + " is a physical folder.");
    }
    MessageBox.Show("There are " + 
theFolder.ProjectItems.Count.ToString() + " Web references.");
}

.NET Framework 보안

참고 항목

참조

VSProject2 인터페이스

VSLangProj80 네임스페이스