SiteMapSection Klass

Definition

Definierar konfigurationsinställningar som används för att stödja infrastrukturen för att konfigurera, lagra och återge webbplatsnavigering. Det går inte att ärva den här klassen.

public ref class SiteMapSection sealed : System::Configuration::ConfigurationSection
public sealed class SiteMapSection : System.Configuration.ConfigurationSection
type SiteMapSection = class
    inherit ConfigurationSection
Public NotInheritable Class SiteMapSection
Inherits ConfigurationSection
Arv

Exempel

Det här exemplet visar hur du anger värden deklarativt för flera attribut i siteMap avsnittet, som också kan nås som medlemmar i SiteMapSection klassen.

Följande konfigurationsfilexempel visar hur du anger värden deklarativt för siteMap avsnittet.

<system.web>
  <siteMap defaultProvider="XmlSiteMapReader" enabled="true">
    <providers>
      <clear />
      <add
        name="XmlSiteMapReader"
        type="XmlSiteMapProvider, System.Web, Version=1.1.3300.0,
              Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
        siteMapFile="my.sitemap"
        description="XmlSiteMapProvider that loads my.sitemap"/>
    </providers>
  </siteMap>
</system.web>

Följande kodexempel visar hur du SiteMapSection använder klassen.

#region Using directives

using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Web;
using System.Web.Configuration;

#endregion

namespace Samples.Aspnet.SystemWebConfiguration
{
  class UsingSiteMapSection
  {
    static void Main(string[] args)
    {
      try
      {
        // Set the path of the config file.
        string configPath = "";

        // Get the Web application configuration object.
        Configuration config = WebConfigurationManager.OpenWebConfiguration(configPath);

        // Get the section related object.
        SiteMapSection configSection = 
          (SiteMapSection)config.GetSection("system.web/siteMap");

        // Display title and info.
        Console.WriteLine("ASP.NET Configuration Info");
        Console.WriteLine();

        // Display Config details.
        Console.WriteLine("File Path: {0}", 
          config.FilePath);
        Console.WriteLine("Section Path: {0}",
          configSection.SectionInformation.Name);
        // Display Default Provider.
        Console.WriteLine("Default Provider: {0}",
          configSection.DefaultProvider);

        // Set Default Provider.
        configSection.DefaultProvider = 
          "SiteMapProviderName";

        // Display Enabled value.
        Console.WriteLine("Enabled: {0}", configSection.Enabled);

        // Set Enabled value.
        configSection.Enabled = true;

        // Display the number of Providers
        Console.WriteLine("Providers Collection Count: {0}",
          configSection.Providers.Count);

        // Display elements of the Providers collection property.
        foreach (ProviderSettings providerItem in configSection.Providers)
        {
          Console.WriteLine();
          Console.WriteLine("Provider Details:");
          Console.WriteLine("Name: {0}", providerItem.Name);
          Console.WriteLine("Type: {0}", providerItem.Type);
        }

        // Update if not locked.
        if (!configSection.SectionInformation.IsLocked)
        {
          config.Save();
          Console.WriteLine("** Configuration updated.");
        }
        else
        {
          Console.WriteLine("** Could not update, section is locked.");
        }
      }

      catch (Exception e)
      {
        // Unknown error.
        Console.WriteLine(e.ToString());
      }

      // Display and wait
      Console.ReadLine();
    }
  }
}
Imports System.Collections.Generic
Imports System.Text
Imports System.Configuration
Imports System.Web
Imports System.Web.Configuration

Namespace Samples.Aspnet.SystemWebConfiguration
  Class UsingSiteMapSection
    Public Shared Sub Main()
      Try
        ' Set the path of the config file.
        Dim configPath As String = ""

        ' Get the Web application configuration object.
        Dim config As System.Configuration.Configuration = _
         System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(configPath)

        ' Get the section related object.
        Dim configSection As System.Web.Configuration.SiteMapSection = _
         CType(config.GetSection("system.web/siteMap"), _
         System.Web.Configuration.SiteMapSection)

        ' Display title and info.
        Console.WriteLine("ASP.NET Configuration Info")
        Console.WriteLine()

        ' Display Config details.
        Console.WriteLine("File Path: {0}", config.FilePath)
        Console.WriteLine("Section Path: {0}", configSection.SectionInformation.Name)

        ' Display Default Provider.
        Console.WriteLine("Default Provider: {0}", _
         configSection.DefaultProvider)

        ' Set Default Provider.
        configSection.DefaultProvider = "SiteMapProviderName"

        ' Display Enabled value.
        Console.WriteLine("Enabled: {0}", configSection.Enabled)

        ' Set Enabled value.
        configSection.Enabled = True

        ' Display the number of Providers
        Console.WriteLine("Providers Collection Count: {0}", _
         configSection.Providers.Count)

        ' Display elements of the Providers collection property.
        For Each providerItem As ProviderSettings In configSection.Providers()
          Console.WriteLine()
          Console.WriteLine("Provider Details -")
          Console.WriteLine("Name: {0}", providerItem.Name)
          Console.WriteLine("Type: {0}", providerItem.Type)
        Next

        ' Update if not locked.
        If Not configSection.SectionInformation.IsLocked Then
          config.Save()
          Console.WriteLine("** Configuration updated.")
        Else
          Console.WriteLine("** Could not update, section is locked.")
        End If

      Catch e As Exception
        ' Unknown error.
        Console.WriteLine(e.ToString())
      End Try

      ' Display and wait
      Console.ReadLine()
    End Sub
  End Class
End Namespace

Kommentarer

Klassen SiteMapSection ger ett sätt att programmatiskt komma åt och ändra innehållet i avsnittet för konfigurationsfil siteMap .

Konstruktorer

Name Description
SiteMapSection()

Initierar en ny instans av SiteMapSection klassen med hjälp av standardinställningar.

Egenskaper

Name Description
CurrentConfiguration

Hämtar en referens till den översta instansen Configuration som representerar konfigurationshierarkin som den aktuella ConfigurationElement instansen tillhör.

(Ärvd från ConfigurationElement)
DefaultProvider

Hämtar eller anger namnet på standardnavigeringsprovidern.

ElementInformation

Hämtar ett ElementInformation objekt som innehåller den icke-anpassningsbara informationen och funktionerna i ConfigurationElement objektet.

(Ärvd från ConfigurationElement)
ElementProperty

Hämtar objektet ConfigurationElementProperty som representerar ConfigurationElement själva objektet.

(Ärvd från ConfigurationElement)
Enabled

Hämtar eller anger ett värde som anger om ASP.NET webbplatsöversiktsfunktionen är aktiverad.

EvaluationContext

Hämtar ContextInformation-objektet för ConfigurationElement-objektet.

(Ärvd från ConfigurationElement)
HasContext

Hämtar ett värde som anger om egenskapen CurrentConfiguration är null.

(Ärvd från ConfigurationElement)
Item[ConfigurationProperty]

Hämtar eller anger en egenskap eller ett attribut för det här konfigurationselementet.

(Ärvd från ConfigurationElement)
Item[String]

Hämtar eller anger en egenskap, ett attribut eller ett underordnat element i det här konfigurationselementet.

(Ärvd från ConfigurationElement)
LockAllAttributesExcept

Hämtar samlingen med låsta attribut.

(Ärvd från ConfigurationElement)
LockAllElementsExcept

Hämtar samlingen med låsta element.

(Ärvd från ConfigurationElement)
LockAttributes

Hämtar samlingen med låsta attribut.

(Ärvd från ConfigurationElement)
LockElements

Hämtar samlingen med låsta element.

(Ärvd från ConfigurationElement)
LockItem

Hämtar eller anger ett värde som anger om elementet är låst.

(Ärvd från ConfigurationElement)
Properties

Hämtar samlingen med egenskaper.

(Ärvd från ConfigurationElement)
Providers

Hämtar en ProviderSettingsCollection samling ProviderSettings objekt.

SectionInformation

Hämtar ett SectionInformation objekt som innehåller den icke-anpassningsbara informationen och funktionerna i ConfigurationSection objektet.

(Ärvd från ConfigurationSection)

Metoder

Name Description
DeserializeElement(XmlReader, Boolean)

Läser XML från konfigurationsfilen.

(Ärvd från ConfigurationElement)
DeserializeSection(XmlReader)

Läser XML från konfigurationsfilen.

(Ärvd från ConfigurationSection)
Equals(Object)

Jämför den aktuella ConfigurationElement instansen med det angivna objektet.

(Ärvd från ConfigurationElement)
GetHashCode()

Hämtar ett unikt värde som representerar den aktuella ConfigurationElement instansen.

(Ärvd från ConfigurationElement)
GetRuntimeObject()

Returnerar ett anpassat objekt när det åsidosättas i en härledd klass.

(Ärvd från ConfigurationSection)
GetTransformedAssemblyString(String)

Returnerar den transformerade versionen av det angivna sammansättningsnamnet.

(Ärvd från ConfigurationElement)
GetTransformedTypeString(String)

Returnerar den transformerade versionen av det angivna typnamnet.

(Ärvd från ConfigurationElement)
GetType()

Hämtar den aktuella instansen Type .

(Ärvd från Object)
Init()

Anger objektets ConfigurationElement ursprungliga tillstånd.

(Ärvd från ConfigurationElement)
InitializeDefault()

Används för att initiera en standarduppsättning med värden för ConfigurationElement objektet.

(Ärvd från ConfigurationElement)
IsModified()

Anger om det här konfigurationselementet har ändrats sedan det senast sparades eller lästes in när det implementerades i en härledd klass.

(Ärvd från ConfigurationSection)
IsReadOnly()

Hämtar ett värde som anger om objektet ConfigurationElement är skrivskyddat.

(Ärvd från ConfigurationElement)
ListErrors(IList)

Lägger till felen invalid-property i det här ConfigurationElement objektet, och i alla underelement, i den överförda listan.

(Ärvd från ConfigurationElement)
MemberwiseClone()

Skapar en ytlig kopia av den aktuella Object.

(Ärvd från Object)
OnDeserializeUnrecognizedAttribute(String, String)

Hämtar ett värde som anger om ett okänt attribut påträffas under deserialiseringen.

(Ärvd från ConfigurationElement)
OnDeserializeUnrecognizedElement(String, XmlReader)

Hämtar ett värde som anger om ett okänt element påträffas under deserialiseringen.

(Ärvd från ConfigurationElement)
OnRequiredPropertyNotFound(String)

Utlöser ett undantag när en obligatorisk egenskap inte hittas.

(Ärvd från ConfigurationElement)
PostDeserialize()

Anropas efter deserialisering.

(Ärvd från ConfigurationElement)
PreSerialize(XmlWriter)

Anropas före serialisering.

(Ärvd från ConfigurationElement)
Reset(ConfigurationElement)

Återställer objektets interna tillstånd ConfigurationElement , inklusive låsen och egenskapssamlingarna.

(Ärvd från ConfigurationElement)
ResetModified()

Återställer värdet för metoden till IsModified() när den false implementeras i en härledd klass.

(Ärvd från ConfigurationSection)
SerializeElement(XmlWriter, Boolean)

Skriver innehållet i det här konfigurationselementet till konfigurationsfilen när det implementeras i en härledd klass.

(Ärvd från ConfigurationElement)
SerializeSection(ConfigurationElement, String, ConfigurationSaveMode)

Skapar en XML-sträng som innehåller en icke-komprimerad vy av ConfigurationSection objektet som ett enda avsnitt för att skriva till en fil.

(Ärvd från ConfigurationSection)
SerializeToXmlElement(XmlWriter, String)

Skriver de yttre taggarna för det här konfigurationselementet till konfigurationsfilen när det implementeras i en härledd klass.

(Ärvd från ConfigurationElement)
SetPropertyValue(ConfigurationProperty, Object, Boolean)

Anger en egenskap till det angivna värdet.

(Ärvd från ConfigurationElement)
SetReadOnly()

Anger egenskapen IsReadOnly() för ConfigurationElement objektet och alla underelement.

(Ärvd från ConfigurationElement)
ShouldSerializeElementInTargetVersion(ConfigurationElement, String, FrameworkName)

Anger om det angivna elementet ska serialiseras när konfigurationsobjekthierarkin serialiseras för den angivna målversionen av .NET Framework.

(Ärvd från ConfigurationSection)
ShouldSerializePropertyInTargetVersion(ConfigurationProperty, String, FrameworkName, ConfigurationElement)

Anger om den angivna egenskapen ska serialiseras när konfigurationsobjekthierarkin serialiseras för den angivna målversionen av .NET Framework.

(Ärvd från ConfigurationSection)
ShouldSerializeSectionInTargetVersion(FrameworkName)

Anger om den aktuella ConfigurationSection-instansen ska serialiseras när konfigurationsobjekthierarkin serialiseras för den angivna målversionen av .NET Framework.

(Ärvd från ConfigurationSection)
ToString()

Returnerar en sträng som representerar det aktuella objektet.

(Ärvd från Object)
Unmerge(ConfigurationElement, ConfigurationElement, ConfigurationSaveMode)

Ändrar objektet ConfigurationElement för att ta bort alla värden som inte ska sparas.

(Ärvd från ConfigurationElement)

Gäller för

Se även