디자이너가 생성 한 설정을 통해 수행 할 수 있는지 확실하지 않지만 자주 사용하지 않으므로 잘못되었을 수 있습니다. 그러나, 당신이 이것을 할 수있는 다른 방법이 있습니다 : 당신 자신의 ConfigurationSection 만들기. 여기
은 예입니다
public class MyProperties : ConfigurationSection {
[ConfigurationProperty("A")]
public MySettings A
{
get { return (MySettings)this["A"]; }
set { this["A"] = value; }
}
[ConfigurationProperty("B")]
public MySettings B
{
get { return (MySettings)this["B"]; }
set { this["B"] = value; }
}
}
public class MySettings : ConfigurationElement {
[ConfigurationProperty("greeting")]
public string Greeting
{
get { return (string)this["greeting"]; }
set { this["greeting"] = value; }
}
}
그리고 당신의 app.config/Web.config의 다음과 같은 필요 :
는
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="mySettings" type="Namespace.MyProperties, Assembly"/>
</configSections>
<mySettings>
<A greeting="Hello from A!" />
<B greeting="Hello from B" />
</mySettings>
</configuration>
점에서 오타가있을 수 있지만 전체적인 아이디어가있다. 희망이 도움이됩니다.
왜? 생성 된 설정 클래스 정의에 인터페이스를 추가하면됩니다. 단점은 설정을 변경할 때마다 덮어 쓰게된다는 것입니다.어쨌든 색 구성표에는 여전히 적합합니다. – Harry