VSProject2.WebReferencesFolder 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取 ProjectItem 表示项目的 Web 引用文件夹的对象。 如果该文件夹不存在,则此属性不 (空引用) 返回任何内容。
public:
property EnvDTE::ProjectItem ^ WebReferencesFolder { EnvDTE::ProjectItem ^ get(); };
public:
property EnvDTE::ProjectItem ^ WebReferencesFolder { EnvDTE::ProjectItem ^ get(); };
[System.Runtime.InteropServices.DispId(6)]
public EnvDTE.ProjectItem WebReferencesFolder { [System.Runtime.InteropServices.DispId(6)] get; }
[<System.Runtime.InteropServices.DispId(6)>]
[<get: System.Runtime.InteropServices.DispId(6)>]
member this.WebReferencesFolder : EnvDTE.ProjectItem
Public ReadOnly Property WebReferencesFolder As ProjectItem
属性值
一个 ProjectItem 表示 "Web 引用" 文件夹的对象。
实现
- 属性
示例
此示例创建一个 "Web 引用" 文件夹(如果尚不存在),并在消息框中显示某些文件夹属性。 若要将此示例作为外接程序运行,请参阅 如何:编译和运行自动化对象模型代码示例。 Visual Basic Visual C# 在运行此示例之前,请打开或项目。
[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.");
}
注解
可以通过访问的属性来检索项目的 Web 引用 ProjectItems WebReferencesFolder 。
一个项目最多包含一个 "Web 引用" 文件夹。 可以通过使用方法来创建文件夹 CreateWebReferencesFolder 。 此外,通过使用方法将第一个 Web 引用添加到项目中时,会自动创建文件夹 CreateWebReferencesFolder 。
在 Visual Basic 或 Visual C# 项目中, Kind 项目项的属性 WebReferencesFolder 始终为, vsProjectItemKindPhysicalFolder 因为 Visual Basic 和 Visual C# 项目仅支持物理文件。