0

System.Configuration接続文字列構成クラスは次を定義します。

ConnectionStringsSection : ConfigurationSection

ConnectionStringSettingsCollection : ConfigurationElementCollection

ConnectionStringSettings : ConfigurationElement

ただし、構成ファイルのセクションは次のようになります。

 <connectionStrings>
    <add name="Foo" connectionString="Whatever" />
 </connectionStrings>

ConnectionStringSettingsCollectionしたがって、は暗黙的であるように見えます。

冗長レベルのネストを削除するために、自分の構成セクションでこれと同じ動作を行いたいのですが、その方法が見つかりませんでした。

4

1 に答える 1

2

デフォルトのコレクションを適切なConfigurationProperty属性で装飾する必要があります。

[ConfigurationProperty("", Options = ConfigurationPropertyOptions.IsDefaultCollection)]
于 2012-01-09T17:27:37.393 に答える