Właściwość VSProject2.WebReferencesFolder —
Pobiera ProjectItem obiekt reprezentujący folder sieć Web odwołania projekt. Jeśli folder nie istnieje, ta właściwość zwraca Nothing ( nullodwołanie o wartości null (Nothing w języku Visual Basic) odniesienia).
Przestrzeń nazw: VSLangProj80
Zestaw: VSLangProj80 (w VSLangProj80.dll)
Składnia
'Deklaracja
ReadOnly Property WebReferencesFolder As ProjectItem
ProjectItem WebReferencesFolder { get; }
property ProjectItem^ WebReferencesFolder {
ProjectItem^ get ();
}
abstract WebReferencesFolder : ProjectItem
function get WebReferencesFolder () : ProjectItem
Wartość właściwości
Typ: EnvDTE.ProjectItem
A ProjectItem obiekt reprezentujący folder odwołań sieć Web .
Uwagi
Odwołania do projekt sieć Web mogą być pobierane przez uzyskiwanie dostępu do ProjectItems właściwość WebReferencesFolder.
projekt zawiera co najwyżej jeden folder odwołań sieć Web .Folder może zostać utworzony za pomocą CreateWebReferencesFolder metoda. Ponadto, folder jest tworzona automatycznie po pierwszym odwołanie sieć Web jest dodawany do projekt przy użyciu CreateWebReferencesFolder metoda.
W Visual Basic lub Visual C# projekt Kind właściwość WebReferencesFolderelementu projekt jest zawsze vsProjectItemKindPhysicalFolder ponieważ Visual Basic i Visual C# projekty obsługują tylko plików fizycznych.
Przykłady
W tym przykładzie tworzy folder sieci sieć Web odniesienia, jeżeli jeszcze nie istnieje i są wyświetlane niektóre właściwości folderu w polu komunikat.Aby uruchomić ten przykład, jako dodatek, zobacz Jak: skompilować i uruchomić przykłady kodu modelu obiektu automatyzacji.Otwórz Visual Basic lub Visual C# projekt przed uruchomieniem tego przykładu.
[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.");
}
Zabezpieczenia programu .NET Framework
- Pełne zaufanie do bezpośredniego wywołującego. Tego elementu członkowskiego nie można używać w kodzie częściowo zaufanym. Aby uzyskać więcej informacji, zobacz Przy użyciu bibliotek z częściowo zaufanego kodu..