slowcheetah转换配置文件中元素的值

时间:2012-03-26 19:24:18

标签: c# xpath configuration configurationmanager slowcheetah

我知道如何使用SlowCheetah更改属性的值,但我如何更改元素的值。

app.Debug.config:

 <applicationSettings>
  <MyProgram.Properties.Settings>
    <setting name="aName" serializeAs="String">
      <value>myName</value>
    </setting>
  </MyProgram.Properties.Settings>
 </applicationSettings>

这是我在app.Staging.config中失败的尝试:

 <applicationSetting>
   <MyProgram.Properties.Settings>
     <setting name="aName" serializeAs="String">
        <value xdt:Transform="Replace" xdt:Locator="Match(value)">newName</value>
     </setting>
   </MyProgram.Properties.Settings>
</applicationSetting>

1 个答案:

答案 0 :(得分:15)

<applicationSetting>    
  <MyProgram.Properties.Settings>      
    <setting name="aName" serializeAs="String" xdt:Locator="Match(name)">         
      <value xdt:Transform="Replace">newName</value>     
    </setting>    
  </MyProgram.Properties.Settings> 
</applicationSetting> 

应该这样做!