プログラムによってカスタム セクションを実装する方法を次のコード例に示します。
属性モデルを使用して実装されたカスタム セクションを実装および使用する方法を示す完全な例については、ConfigurationElement のトピックを参照してください。
これは、前の例に適用されている構成ファイルの抜粋です。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="CustomSection" type="Samples.AspNet, CustomConfigurationSection, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" allowDefinition="Everywhere" allowExeDefinition="MachineToApplication" restartOnExternalChanges="true" />
</configSections>
<CustomSection fileName="default.txt" maxUsers="1000" maxIdleTime="00:15:00" />
</configuration>