ConfigurationSectionGroup クラス
アセンブリ: System.Configuration (system.configuration.dll 内)


一部の構成セクションは相互に関連付けられているので、多くの場合、このような構成セクションを 1 つのセクション グループにグループ化すると便利です。ConfigurationSectionGroup クラスは、構成ファイル内の sectionGroup XML 要素を表します。
この ConfigurationSectionGroup に格納されているセクションにアクセスするには、Sections プロパティを使用します。
ConfigurationSectionGroup には、SectionGroups プロパティを使用してアクセスできる他の ConfigurationSectionGroup オブジェクトも格納できます。

ConfigurationSectionGroup を使用する方法を次のコード例に示します。
Imports System Imports System.Collections Imports System.Configuration Class UsingConfigurationSectionGroup Private Shared indentLevel As Integer = 0 Public Shared Sub Main(ByVal args() As String) ' Get the application configuration file. Dim config _ As System.Configuration.Configuration = _ ConfigurationManager.OpenExeConfiguration( _ ConfigurationUserLevel.None) ' Get the collection of the section groups. Dim sectionGroups _ As ConfigurationSectionGroupCollection = _ config.SectionGroups ShowSectionGroupCollectionInfo(sectionGroups) End Sub 'Main Shared Function getSpacer() As String Dim spacer As String = "" Dim i As Integer For i = 0 To indentLevel - 1 spacer = spacer + " " Next i Return spacer End Function 'getSpacer Overloads Shared Sub ForceDeclaration( _ ByVal sectionGroup As ConfigurationSectionGroup) ' Get the application configuration file. Dim config _ As System.Configuration.Configuration = _ ConfigurationManager.OpenExeConfiguration( _ ConfigurationUserLevel.None) sectionGroup.ForceDeclaration() config.Save(ConfigurationSaveMode.Full) Console.WriteLine( _ "Forced declaration for the group: {0}", _ sectionGroup.Name) End Sub 'ForceDeclaration Overloads Shared Sub ForceDeclaration( _ ByVal sectionGroup _ As ConfigurationSectionGroup, _ ByVal force As Boolean) sectionGroup.ForceDeclaration(force) Console.WriteLine( _ "Forced declaration for the group: {0} is {1}", _ sectionGroup.Name, force.ToString()) End Sub 'ForceDeclaration Shared Sub ShowSectionGroupCollectionInfo( _ ByVal sectionGroups _ As ConfigurationSectionGroupCollection) Dim groupName As String For Each groupName In sectionGroups.Keys Dim sectionGroup _ As ConfigurationSectionGroup = _ CType(sectionGroups(groupName), _ ConfigurationSectionGroup) ShowSectionGroupInfo(sectionGroup) If sectionGroup.Name = "system.web" Then ForceDeclaration(sectionGroup, True) End If Next groupName End Sub 'ShowSectionGroupCollectionInfo Shared Sub ShowSectionGroupInfo( _ ByVal sectionGroup As ConfigurationSectionGroup) ' Get the group name including the ' parent group names. Console.WriteLine((getSpacer() + _ "Section Group Name: " + sectionGroup.Name)) ' Get the group name without including ' the parent group names. Console.WriteLine((getSpacer() + _ "Section Group Name: " + _ sectionGroup.SectionGroupName)) indentLevel += 1 Console.WriteLine((getSpacer() + _ "Type: " + sectionGroup.Type)) Console.WriteLine((getSpacer() + _ "Is Group Required?: " + _ sectionGroup.IsDeclarationRequired.ToString())) Console.WriteLine((getSpacer() + _ "Is Group Declared?: " + _ sectionGroup.IsDeclared.ToString())) Console.WriteLine((getSpacer() + _ "Contained Sections:")) indentLevel += 1 Dim sectionCollection _ As ConfigurationSectionCollection = _ sectionGroup.Sections Dim sectionName As String For Each sectionName In sectionCollection.Keys Dim section As ConfigurationSection = _ CType(sectionCollection( _ sectionName), ConfigurationSection) Console.WriteLine((getSpacer() + _ "Section Name:" + _ section.SectionInformation.Name)) Next sectionName indentLevel -= 1 Console.WriteLine((getSpacer() + _ "Contained Section Groups:")) indentLevel += 1 Dim sectionGroups _ As ConfigurationSectionGroupCollection = _ sectionGroup.SectionGroups ShowSectionGroupCollectionInfo(sectionGroups) indentLevel -= 1 End Sub 'ShowSectionGroupInfo End Class 'UsingConfigurationSectionGroup
using System; using System.Collections; using System.Configuration; namespace Samples.AspNet { class UsingConfigurationSectionGroup { static int indentLevel = 0; static void Main(string[] args) { // Get the application configuration file. System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration( ConfigurationUserLevel.None); // Get the collection of the section groups. ConfigurationSectionGroupCollection sectionGroups = config.SectionGroups; ShowSectionGroupCollectionInfo(sectionGroups); } static String getSpacer() { String spacer = ""; for (int i = 0; i < indentLevel; i++) { spacer = spacer + " "; } return spacer; } static void ForceDeclaration( ConfigurationSectionGroup sectionGroup) { // Get the application configuration file. System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration( ConfigurationUserLevel.None); sectionGroup.ForceDeclaration(); config.Save(ConfigurationSaveMode.Full); Console.WriteLine( "Forced declaration for the group: {0}", sectionGroup.Name); } static void ForceDeclaration( ConfigurationSectionGroup sectionGroup, bool force) { sectionGroup.ForceDeclaration(force); Console.WriteLine( "Forced declaration for the group: {0} is {1}", sectionGroup.Name, force.ToString()); } static void ShowSectionGroupCollectionInfo( ConfigurationSectionGroupCollection sectionGroups) { foreach (String groupName in sectionGroups.Keys) { ConfigurationSectionGroup sectionGroup = (ConfigurationSectionGroup)sectionGroups[groupName]; ShowSectionGroupInfo(sectionGroup); if (sectionGroup.Name == "system.web") { ForceDeclaration(sectionGroup, true); } } } static void ShowSectionGroupInfo( ConfigurationSectionGroup sectionGroup) { // Get the group name including the // parent group names. Console.WriteLine(getSpacer() + "Section Group Name: " + sectionGroup.Name); // Get the group name without including // the parent group names. Console.WriteLine(getSpacer() + "Section Group Name: " + sectionGroup.SectionGroupName); indentLevel++; Console.WriteLine(getSpacer() + "Type: " + sectionGroup.Type); Console.WriteLine(getSpacer() + "Is Group Required?: " + sectionGroup.IsDeclarationRequired); Console.WriteLine(getSpacer() + "Is Group Declared?: " + sectionGroup.IsDeclared); Console.WriteLine(getSpacer() + "Contained Sections:"); indentLevel++; ConfigurationSectionCollection sectionCollection = sectionGroup.Sections; foreach (String sectionName in sectionCollection.Keys) { ConfigurationSection section = (ConfigurationSection)sectionCollection[sectionName]; Console.WriteLine(getSpacer() + "Section Name:" + section.SectionInformation.Name); } indentLevel--; Console.WriteLine(getSpacer() + "Contained Section Groups:"); indentLevel++; ConfigurationSectionGroupCollection sectionGroups = sectionGroup.SectionGroups; ShowSectionGroupCollectionInfo(sectionGroups); indentLevel--; } }



Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


ConfigurationSectionGroup コンストラクタ
アセンブリ: System.Configuration (system.configuration.dll 内)


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


ConfigurationSectionGroup プロパティ

名前 | 説明 | |
---|---|---|
![]() | IsDeclarationRequired | この ConfigurationSectionGroup オブジェクト宣言が必要かどうかを示す値を取得します。 |
![]() | IsDeclared | ConfigurationSectionGroup オブジェクトが宣言されているかどうかを示す値を取得します。 |
![]() | Name | この ConfigurationSectionGroup オブジェクトの名前プロパティを取得します。 |
![]() | SectionGroupName | この ConfigurationSectionGroup に関連付けられているセクション グループ名を取得します。 |
![]() | SectionGroups | この ConfigurationSectionGroup オブジェクトの子であるすべての ConfigurationSectionGroup オブジェクトを格納している ConfigurationSectionGroup オブジェクトを取得します。 |
![]() | Sections | この ConfigurationSectionGroup 内のすべての ConfigurationSection オブジェクトを格納している ConfigurationSectionCollection を取得します。 |
![]() | Type | この ConfigurationSectionGroup オブジェクトの型を取得または設定します。 |

ConfigurationSectionGroup メソッド

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | ForceDeclaration | オーバーロードされます。 この ConfigurationSectionGroup オブジェクトの宣言を強制的に行います。 |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

ConfigurationSectionGroup メンバ
ConfigurationSectionGroup データ型で公開されるメンバを以下の表に示します。


名前 | 説明 | |
---|---|---|
![]() | IsDeclarationRequired | この ConfigurationSectionGroup オブジェクト宣言が必要かどうかを示す値を取得します。 |
![]() | IsDeclared | ConfigurationSectionGroup オブジェクトが宣言されているかどうかを示す値を取得します。 |
![]() | Name | この ConfigurationSectionGroup オブジェクトの名前プロパティを取得します。 |
![]() | SectionGroupName | この ConfigurationSectionGroup に関連付けられているセクション グループ名を取得します。 |
![]() | SectionGroups | この ConfigurationSectionGroup オブジェクトの子であるすべての ConfigurationSectionGroup オブジェクトを格納している ConfigurationSectionGroup オブジェクトを取得します。 |
![]() | Sections | この ConfigurationSectionGroup 内のすべての ConfigurationSection オブジェクトを格納している ConfigurationSectionCollection を取得します。 |
![]() | Type | この ConfigurationSectionGroup オブジェクトの型を取得または設定します。 |

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | ForceDeclaration | オーバーロードされます。 この ConfigurationSectionGroup オブジェクトの宣言を強制的に行います。 |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

- ConfigurationSectionGroupのページへのリンク