다음을 통해 공유


SectionGroup.Sections 속성

정의

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

public:
 property Microsoft::Web::Administration::SectionDefinitionCollection ^ Sections { Microsoft::Web::Administration::SectionDefinitionCollection ^ get(); };
public Microsoft.Web.Administration.SectionDefinitionCollection Sections { get; }
member this.Sections : Microsoft.Web.Administration.SectionDefinitionCollection
Public ReadOnly Property Sections As SectionDefinitionCollection

속성 값

SectionDefinitionCollectionSectionGroup 개체의 모든 개체를 ConfigurationSection 포함하는 개체입니다.

예제

다음 예제는 Sections 속성입니다.


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

    }
}

설명

섹션 정의를 찾을 수 없으면 이 속성은 빈 컬렉션을 가져옵니다.

적용 대상