다음을 통해 공유


SectionGroup 클래스

정의

관련 구성 섹션 그룹 또는 구성 섹션 정의 그룹에 대한 액세스를 제공합니다.

public ref class SectionGroup sealed
public sealed class SectionGroup
type SectionGroup = class
Public NotInheritable Class SectionGroup
상속
SectionGroup

예제

다음 예제는 SectionGroup 클래스입니다.


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

    }
}

설명

일부 구성 섹션은 관련이 있으므로 단일 섹션 그룹으로 그룹화하면 편리합니다. 클래스는 SectionGroup 구성 파일의 <sectionGroup> XML 요소를 나타냅니다.

사용 된이 Sections 개체의 섹션 SectionGroup 에 액세스 하는 속성입니다.

에는 SectionGroup 속성을 통해 SectionGroups 액세스할 수 있는 다른 SectionGroup 개체도 포함될 수 있습니다.

속성

Name

구성 섹션 그룹의 이름을 가져옵니다.

SectionGroups

중첩된 구성 섹션 그룹의 컬렉션을 가져옵니다.

Sections

중첩된 구성 섹션 정의의 컬렉션을 가져옵니다.

Type

구성 섹션 그룹의 .NET Framework 형식을 가져오거나 설정합니다.

적용 대상