SectionGroup Classe

Définition

Fournit l’accès à un groupe de groupes de sections de configuration associés ou à des définitions de section de configuration.

public ref class SectionGroup sealed
public sealed class SectionGroup
type SectionGroup = class
Public NotInheritable Class SectionGroup
Héritage
SectionGroup

Exemples

L’exemple suivant illustre la SectionGroup classe .


using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Web.Administration;
using Microsoft.Web.Management;

namespace AdministrationSnippets
{
    public class AdministrationSectionDefinition
    {
        // List all configuration sections in applicationHost.config
        public void ShowAllSections()
        {
            ServerManager manager = new ServerManager();
            SectionGroup rootGroup = 
                manager.GetApplicationHostConfiguration().RootSectionGroup;
            ShowGroup(rootGroup, -1);

        }

        private void ShowGroup(SectionGroup group, int indentLevel)
        {
            Console.Write("".PadLeft(++indentLevel, ' '));
            string grpName = String.IsNullOrEmpty(group.Name) ? "{root}" : group.Name;
            Console.WriteLine("+ Section Group: {0}; Sub-groups: {1}; Sections: {2}",
                grpName, group.SectionGroups.Count, group.Sections.Count);

            foreach (SectionGroup grp in group.SectionGroups)
            {
                ShowGroup(grp, indentLevel);
            }

            string path = String.Concat(group.Name, "/");

            foreach (SectionDefinition def in group.Sections)
            {
                Console.Write("".PadLeft(indentLevel, ' '));
                Console.WriteLine("|_Name:                {0}", String.Concat(path,def.Name));
                Console.Write("".PadLeft(indentLevel, ' '));
                Console.WriteLine("|_AllowDefinition:     {0}", def.AllowDefinition);
                Console.Write("".PadLeft(indentLevel, ' '));
                Console.WriteLine("|_AllowLocation:       {0}", def.AllowLocation);
                Console.Write("".PadLeft(indentLevel, ' '));
                Console.WriteLine("|_OverrideModeDefault: {0}", def.OverrideModeDefault);
                Console.Write("".PadLeft(indentLevel, ' '));
                Console.WriteLine("|_Type:                {0}\r\n", 
                    String.IsNullOrEmpty(def.Type) ? "null" : def.Type);
            }
        }

    }
}

Remarques

Étant donné que certaines sections de configuration sont liées, il est souvent pratique de les regrouper dans un seul groupe de sections. La SectionGroup classe représente l’élément <sectionGroup> XML dans un fichier de configuration.

Utilisez la Sections propriété pour accéder aux sections de cet SectionGroup objet.

Un SectionGroup peut également contenir d’autres SectionGroup objets auxquels vous pouvez accéder via la SectionGroups propriété .

Propriétés

Name

Obtient le nom du groupe de sections de configuration.

SectionGroups

Obtient une collection de groupes de sections de configuration imbriqués.

Sections

Obtient une collection de définitions de section de configuration imbriquées.

Type

Obtient ou définit le type .NET Framework du groupe de sections de configuration.

S’applique à