我的项目中有这段代码
public class SchedulersConfiguration : IConfigurationSectionHandler
{
public object Create(object parent, object configContext, XmlNode section)
{
// Implementation here to parse xml to object
}
}
以下是我的app.config
中的示例<configSections>
<section name="schedulers" type="MyClass.SchedulersConfiguration, MyDll" />
</configSections>
<schedulers>
<Scheduler name="test1" maxFailureAlert="4" timerType="TypeA" cronExpression="0/10 * * * * ?">
<property name="customerName" value="CUSTOMER_A" />
</Scheduler>
<Scheduler name="test2" maxFailureAlert="3" timerType="TypeB" cronExpression="0/15 * * * * ?" />
<Scheduler name="test3" maxFailureAlert="3" timerType="TypeC" cronExpression="0/20 * * * * ?" />
</schedulers>
我应该怎么做才能修改/添加/删除计划程序部分中的计划程序?
我已经搜索了一段时间,但是,我仍然无法得到答案。
答案 0 :(得分:0)
您可以使用ConfigurationCollectionAttribute实现此目的。它指示.NET Framework创建配置元素集合的实例。它还允许分别使用AddItemName,RemoveItemName和ClearItemsName属性添加,删除和清除元素。
您可以查看更多信息here