Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
257 lines (227 sloc) 18.7 KB
<Type Name="SiteMapProviderCollection" FullName="System.Web.SiteMapProviderCollection">
<TypeSignature Language="C#" Value="public sealed class SiteMapProviderCollection : System.Configuration.Provider.ProviderCollection" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi sealed beforefieldinit SiteMapProviderCollection extends System.Configuration.Provider.ProviderCollection" />
<TypeSignature Language="DocId" Value="T:System.Web.SiteMapProviderCollection" />
<TypeSignature Language="VB.NET" Value="Public NotInheritable Class SiteMapProviderCollection&#xA;Inherits ProviderCollection" />
<TypeSignature Language="C++ CLI" Value="public ref class SiteMapProviderCollection sealed : System::Configuration::Provider::ProviderCollection" />
<TypeSignature Language="F#" Value="type SiteMapProviderCollection = class&#xA; inherit ProviderCollection" />
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Configuration.Provider.ProviderCollection</BaseTypeName>
</Base>
<Interfaces />
<Docs>
<summary>Used by the <see cref="T:System.Web.SiteMap" /> class to track the set of <see cref="T:System.Web.SiteMapProvider" /> objects that are available to the <see cref="T:System.Web.SiteMap" /> during site map initialization. This class cannot be inherited.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.SiteMapProviderCollection> class is a strongly typed <xref:System.Collections.Hashtable> collection of <xref:System.Web.SiteMapProvider> objects. In addition to the two add methods, <xref:System.Web.SiteMapProviderCollection.Add%28System.Configuration.Provider.ProviderBase%29> and <xref:System.Web.SiteMapProviderCollection.Add%28System.Web.SiteMapProvider%29>, the <xref:System.Web.SiteMapProviderCollection> class supports the <xref:System.Web.SiteMapProviderCollection.AddArray%2A> method to add an array of type <xref:System.Web.SiteMapProvider>.
The <xref:System.Web.SiteMapProviderCollection> is used by the <xref:System.Web.SiteMap> class to track the set of <xref:System.Web.SiteMapProvider> objects that are available to the <xref:System.Web.SiteMap> during site map initialization. However, the presence of a <xref:System.Web.SiteMapProvider> in the provider collection does not necessarily mean it is used by a <xref:System.Web.SiteMap> object, only that it is available for use.
When a <xref:System.Web.SiteMapProvider> is stored in the <xref:System.Web.SiteMapProviderCollection>, the <xref:System.Configuration.Provider.ProviderBase.Name%2A> property is used as the key.
## Examples
The following code example demonstrates how to retrieve the <xref:System.Web.SiteMapProviderCollection> object from the <xref:System.Web.SiteMap> object and iterate through it.
If you have more than just the default provider configured for your site, you will see each provider that is displayed. For example, if you are using the sample `AccessSiteMapProvider` found in the <xref:System.Web.SiteMapProvider> class overview, you will see the following output.
```
XmlSiteMapProvider System.Web.XmlSiteMapProvider
AccessSiteMapProvider Samples.AspNet.Controls.AccessSiteMapProvider
```
[!code-aspx-csharp[System.Web.SiteMap_2#1](~/samples/snippets/csharp/VS_Snippets_WebNet/System.Web.SiteMap_2/CS/catalog2cs.aspx#1)]
[!code-aspx-vb[System.Web.SiteMap_2#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/System.Web.SiteMap_2/VB/catalog2vb.aspx#1)]
]]></format>
</remarks>
<altmember cref="T:System.Collections.Hashtable" />
<altmember cref="P:System.Web.SiteMap.Providers" />
<related type="Article" href="https://msdn.microsoft.com/library/4f3ce72a-4fa3-4c3a-94c8-3e2bc4a92d85">ASP.NET Site Navigation Providers</related>
</Docs>
<Members>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public SiteMapProviderCollection ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.SiteMapProviderCollection.#ctor" />
<MemberSignature Language="VB.NET" Value="Public Sub New ()" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; SiteMapProviderCollection();" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName>System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")</AttributeName>
</Attribute>
</Attributes>
<Parameters />
<Docs>
<summary>Initializes a new instance of the <see cref="T:System.Web.SiteMapProviderCollection" /> class.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.SiteMapProviderCollection.%23ctor%2A> parameterless constructor initializes any fields to their default values
]]></format>
</remarks>
<altmember cref="M:System.Web.SiteMapProviderCollection.Add(System.Web.SiteMapProvider)" />
</Docs>
</Member>
<MemberGroup MemberName="Add">
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Adds a site map provider to the <see cref="T:System.Web.SiteMapProviderCollection" /> collection.</summary>
</Docs>
</MemberGroup>
<Member MemberName="Add">
<MemberSignature Language="C#" Value="public override void Add (System.Configuration.Provider.ProviderBase provider);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance void Add(class System.Configuration.Provider.ProviderBase provider) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.SiteMapProviderCollection.Add(System.Configuration.Provider.ProviderBase)" />
<MemberSignature Language="VB.NET" Value="Public Overrides Sub Add (provider As ProviderBase)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; override void Add(System::Configuration::Provider::ProviderBase ^ provider);" />
<MemberSignature Language="F#" Value="override this.Add : System.Configuration.Provider.ProviderBase -&gt; unit" Usage="siteMapProviderCollection.Add provider" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="provider" Type="System.Configuration.Provider.ProviderBase" />
</Parameters>
<Docs>
<param name="provider">The <see cref="T:System.Web.SiteMapProvider" /> to add.</param>
<summary>Adds a <see cref="T:System.Web.SiteMapProvider" /> to the provider collection using the <see cref="P:System.Configuration.Provider.ProviderBase.Name" /> property as the key.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.SiteMapProviderCollection> object that is returned by the <xref:System.Web.SiteMap.Providers%2A> property is read-only. For this reason, you cannot use the <xref:System.Web.SiteMapProviderCollection.Add%2A> and <xref:System.Web.SiteMapProviderCollection.AddArray%2A> methods to add additional providers programmatically at run time. Therefore, the <xref:System.Web.SiteMapProviderCollection.Add%2A> and <xref:System.Web.SiteMapProviderCollection.AddArray%2A> methods are used only in scenarios where you manually create site map provider objects and manage them with an instance of the <xref:System.Web.SiteMapProviderCollection> class. The <xref:System.Web.SiteMapProviderCollection.Add%28System.Configuration.Provider.ProviderBase%29> method checks the type of the specified provider, and then calls the <xref:System.Web.SiteMapProviderCollection.Add%28System.Web.SiteMapProvider%29> method to add it to the collection.
Because the <xref:System.Web.SiteMap> class is static, any <xref:System.Web.SiteMapProvider> contained in its <xref:System.Web.SiteMap.Providers%2A> collection remains for the lifetime of the Web application.
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">The <see cref="P:System.Configuration.Provider.ProviderBase.Name" /> of the <see cref="T:System.Web.SiteMapProvider" /> is <see langword="null" />.</exception>
<exception cref="T:System.ArgumentException">
<paramref name="provider" /> is not an instance of the <see cref="T:System.Web.SiteMapProvider" /> class.
-or-
A <see cref="T:System.Web.SiteMapProvider" /> with the same name already exists in the <see cref="T:System.Web.SiteMapProviderCollection" />.</exception>
<exception cref="T:System.NotSupportedException">The <see cref="T:System.Web.SiteMapProviderCollection" /> is read-only.</exception>
<altmember cref="M:System.Web.SiteMapProviderCollection.AddArray(System.Web.SiteMapProvider[])" />
</Docs>
</Member>
<Member MemberName="Add">
<MemberSignature Language="C#" Value="public void Add (System.Web.SiteMapProvider provider);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void Add(class System.Web.SiteMapProvider provider) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.SiteMapProviderCollection.Add(System.Web.SiteMapProvider)" />
<MemberSignature Language="VB.NET" Value="Public Sub Add (provider As SiteMapProvider)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; void Add(System::Web::SiteMapProvider ^ provider);" />
<MemberSignature Language="F#" Value="override this.Add : System.Web.SiteMapProvider -&gt; unit" Usage="siteMapProviderCollection.Add provider" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="provider" Type="System.Web.SiteMapProvider" />
</Parameters>
<Docs>
<param name="provider">The <see cref="T:System.Web.SiteMapProvider" /> to add.</param>
<summary>Adds a <see cref="T:System.Web.SiteMapProvider" /> object to the provider collection using the <see cref="P:System.Configuration.Provider.ProviderBase.Name" /> property as the key.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.SiteMapProviderCollection> object that is returned by the <xref:System.Web.SiteMap.Providers%2A> property is read-only. For this reason, you cannot use the <xref:System.Web.SiteMapProviderCollection.Add%2A> and <xref:System.Web.SiteMapProviderCollection.AddArray%2A> methods to programmatically add additional providers to the <xref:System.Web.SiteMap> at run time. Therefore, the <xref:System.Web.SiteMapProviderCollection.Add%2A> and <xref:System.Web.SiteMapProviderCollection.AddArray%2A> methods are used only in scenarios where you manually create site map provider objects and manage them with an instance of the <xref:System.Web.SiteMapProviderCollection> class. Use the <xref:System.Web.SiteMapProviderCollection.Add%2A> method when you want to add a single <xref:System.Web.SiteMapProvider> to the <xref:System.Web.SiteMapProviderCollection>.
Because the <xref:System.Web.SiteMap> class is static, any <xref:System.Web.SiteMapProvider> contained in its <xref:System.Web.SiteMap.Providers%2A> collection remains for the lifetime of the Web application.
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="provider" /> is <see langword="null" />.</exception>
<exception cref="T:System.NotSupportedException">The <see cref="T:System.Web.SiteMapProviderCollection" /> is read-only.</exception>
<exception cref="T:System.ArgumentException">A <see cref="T:System.Web.SiteMapProvider" /> with the same name already exists in the <see cref="T:System.Web.SiteMapProviderCollection" />.</exception>
<altmember cref="M:System.Web.SiteMapProviderCollection.Add(System.Configuration.Provider.ProviderBase)" />
</Docs>
</Member>
<Member MemberName="AddArray">
<MemberSignature Language="C#" Value="public void AddArray (System.Web.SiteMapProvider[] providerArray);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void AddArray(class System.Web.SiteMapProvider[] providerArray) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.SiteMapProviderCollection.AddArray(System.Web.SiteMapProvider[])" />
<MemberSignature Language="VB.NET" Value="Public Sub AddArray (providerArray As SiteMapProvider())" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; void AddArray(cli::array &lt;System::Web::SiteMapProvider ^&gt; ^ providerArray);" />
<MemberSignature Language="F#" Value="member this.AddArray : System.Web.SiteMapProvider[] -&gt; unit" Usage="siteMapProviderCollection.AddArray providerArray" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="providerArray" Type="System.Web.SiteMapProvider[]" />
</Parameters>
<Docs>
<param name="providerArray">The array of <see cref="T:System.Web.SiteMapProvider" /> objects to add.</param>
<summary>Adds an array of <see cref="T:System.Web.SiteMapProvider" /> objects into the provider collection using the <see cref="P:System.Configuration.Provider.ProviderBase.Name" /> properties as keys.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.SiteMapProviderCollection> that is returned by the <xref:System.Web.SiteMap.Providers%2A> property is read-only. For this reason, you cannot use the <xref:System.Web.SiteMapProviderCollection.Add%2A> and <xref:System.Web.SiteMapProviderCollection.AddArray%2A> methods to add additional providers programmatically at run time. Therefore, the <xref:System.Web.SiteMapProviderCollection.Add%2A> and <xref:System.Web.SiteMapProviderCollection.AddArray%2A> methods are only used in scenarios where you manually create site map provider objects and manage them with an instance of the <xref:System.Web.SiteMapProviderCollection> class.
Because the <xref:System.Web.SiteMap> class is static, any <xref:System.Web.SiteMapProvider> contained in its <xref:System.Web.SiteMap.Providers%2A> collection remains for the lifetime of the Web application.
]]></format>
</remarks>
<exception cref="T:System.ArgumentException">A <see cref="T:System.Web.SiteMapProvider" /> with the same name already exists in the <see cref="T:System.Web.SiteMapProviderCollection" />.</exception>
<exception cref="T:System.ArgumentNullException">
<paramref name="providerArray" /> is <see langword="null" />.</exception>
<exception cref="T:System.NotSupportedException">The <see cref="T:System.Web.SiteMapProviderCollection" /> is read-only.</exception>
<altmember cref="M:System.Web.SiteMapProviderCollection.Add(System.Web.SiteMapProvider)" />
<altmember cref="M:System.Web.SiteMapProviderCollection.Add(System.Configuration.Provider.ProviderBase)" />
</Docs>
</Member>
<Member MemberName="Item">
<MemberSignature Language="C#" Value="public System.Web.SiteMapProvider this[string name] { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Web.SiteMapProvider Item(string)" />
<MemberSignature Language="DocId" Value="P:System.Web.SiteMapProviderCollection.Item(System.String)" />
<MemberSignature Language="VB.NET" Value="Default Public ReadOnly Property Item(name As String) As SiteMapProvider" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; property System::Web::SiteMapProvider ^ default[System::String ^] { System::Web::SiteMapProvider ^ get(System::String ^ name); };" />
<MemberSignature Language="F#" Value="member this.Item(string) : System.Web.SiteMapProvider" Usage="System.Web.SiteMapProviderCollection.Item" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Web.SiteMapProvider</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="name" Type="System.String" />
</Parameters>
<Docs>
<param name="name">The name of the <see cref="T:System.Web.SiteMapProvider" /> to find.</param>
<summary>Gets a <see cref="T:System.Web.SiteMapProvider" /> object with a specific name from the provider collection.</summary>
<value>A <see cref="T:System.Web.SiteMapProvider" /> that represents a <see cref="T:System.Web.SiteMapProviderCollection" /> element.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
You can use the indexer to iterate over the contents of a <xref:System.Web.SiteMapProviderCollection> object.
## Examples
The following code example demonstrates how to use the <xref:System.Web.SiteMapProviderCollection.Item%2A> property to retrieve the default ASP.NET <xref:System.Web.SiteMapProvider> object from the <xref:System.Web.SiteMapProviderCollection> object that is returned when the <xref:System.Web.SiteMap.Providers%2A> collection is accessed.
[!code-csharp[System.Web.SiteMapProviderCollection_2#1](~/samples/snippets/csharp/VS_Snippets_WebNet/System.Web.SiteMapProviderCollection_2/CS/sitemapprov2cs.aspx#1)]
[!code-vb[System.Web.SiteMapProviderCollection_2#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/System.Web.SiteMapProviderCollection_2/VB/sitemapprov2vb.aspx#1)]
]]></format>
</remarks>
<altmember cref="Overload:System.Web.SiteMapProviderCollection.Add" />
</Docs>
</Member>
</Members>
</Type>
You can’t perform that action at this time.