Envisagez le groupe de configuration suivant dans un fichier .NET .config.Lecture des attributs dans ConfigurationSectionGroup
<MySettingsGroup enabled="true">
<MySettingsSection enabled="true">
</MySettingsSection>
</MySettingsGroup>
Les classes de soutien sont:
public class MySettingsConfigurationSection : ConfigurationSection
{
[ConfigurationProperty("enabled", DefaultValue = true, IsRequired = false)]
public bool Enabled
{
get
{
// works fine
return Convert.ToBoolean(this["enabled"]);
}
}
public class MySettingsConfigurationGroup : ConfigurationSectionGroup
{
[ConfigurationProperty("enabled", DefaultValue = true, IsRequired = false)]
public bool Enabled
{
get
{
// the way to retrieve attributes in sections is not supported by groups
// return Convert.ToBoolean(this["enabled"]);
return true;
}
}
Comment peut être mis en œuvre la propriété Activé sur le MySettingsConfigurationGroup?