いくつかの異なるテーマを使用できるページを作成しており、各テーマに関する情報を web.config に保存します。
新しい sectionGroup を作成してすべてをまとめて保存するか、単にすべてを appSettings に入れる方が効率的ですか?
configSection ソリューション
<configSections>
<sectionGroup name="SchedulerPage">
<section name="Providers" type="System.Configuration.NameValueSectionHandler"/>
<section name="Themes" type="System.Configuration.NameValueSectionHandler"/>
</sectionGroup>
</configSections>
<SchedulerPage>
<Themes>
<add key="PI" value="PISchedulerForm"/>
<add key="UB" value="UBSchedulerForm"/>
</Themes>
</SchedulerPage>
configSection の値にアクセスするには、次のコードを使用しています。
NameValueCollection themes = ConfigurationManager.GetSection("SchedulerPage/Themes") as NameValueCollection;
String SchedulerTheme = themes["UB"];
appSettings ソリューション
<appSettings>
<add key="PITheme" value="PISchedulerForm"/>
<add key="UBTheme" value="UBSchedulerForm"/>
</appSettings>
appSettings の値にアクセスするには、このコードを使用しています
String SchedulerTheme = ConfigurationManager.AppSettings["UBSchedulerForm"].ToString();