Share via


SectionGroup Clase

Definición

Proporciona acceso a un grupo de grupos de secciones de configuración relacionados o definiciones de sección de configuración.

public ref class SectionGroup sealed
public sealed class SectionGroup
type SectionGroup = class
Public NotInheritable Class SectionGroup
Herencia
SectionGroup

Ejemplos

En el ejemplo siguiente se muestra la SectionGroup clase .


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);
            }
        }

    }
}

Comentarios

Dado que algunas secciones de configuración están relacionadas, a menudo es conveniente agruparlas en un único grupo de secciones. La SectionGroup clase representa el <sectionGroup> elemento XML en un archivo de configuración.

Utilice la Sections propiedad para acceder a las secciones de este SectionGroup objeto.

También SectionGroup puede contener otros SectionGroup objetos, a los que puede acceder a través de la SectionGroups propiedad .

Propiedades

Name

Obtiene el nombre del grupo de secciones de configuración.

SectionGroups

Obtiene una colección de grupos de secciones de configuración anidadas.

Sections

Obtiene una colección de definiciones de sección de configuración anidada.

Type

Obtiene o establece el tipo de .NET Framework del grupo de secciones de configuración.

Se aplica a