SectionDefinition.Type 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定實作組態區段的類別類型名稱,並可解譯保存的 XML。
public:
property System::String ^ Type { System::String ^ get(); void set(System::String ^ value); };
public string Type { get; set; }
member this.Type : string with get, set
Public Property Type As String
屬性值
目前 ConfigurationSection 物件的型別名稱。
範例
下列範例示範 Type 屬性。
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);
}
}
}
}
備註
重要
只有在命名空間中的 System.Configuration 類別實作組態檔時,才能使用這個屬性。