2015-11-06 68 views
0

我在我的項目添加/更新/在App.config中刪除自創建部分

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

您可以使用ConfigurationCollectionAttribute來實現此目的。它指示.NET Framework創建配置元素集合的實例。它還允許分別使用AddItemName,RemoveItemName和ClearItemsName屬性添加,刪除和清除元素。

您可以查看詳細信息here

相關問題