【问题标题】:Transform custom configuration setting using Slow Cheater使用 Slow Cheater 转换自定义配置设置
【发布时间】:2013-12-07 06:35:30
【问题描述】:

Slow Cheater 的所有示例似乎都集中在配置文件的应用设置部分。

我很想知道是否可以通过自定义配置设置实现类似的输出。

例如

<MyConfigSection username="debug" password="d3bUg" />

会变成

<MyConfigSection username="release" password="re1eas3" />

编辑 我发现xdt:Transform="Replace" 可以在这个例子中使用。但是,如果我有其他没有改变的属性,我将如何在不从配置中丢失它们的情况下实现呢?

例如

<MyConfigSection username="debug" password="d3bUg" apiKey="12345" />
<MyConfigSection username="release" password="re1eas3" apiKey="12345" />

如果我用过

<MyConfigSection username="release" password="re1eas3" xdt:Transform="Replace" />

那么 apiKey 就会消失

【问题讨论】:

    标签: .net web-config app-config slowcheetah


    【解决方案1】:

    这只会替换您的属性,保留 MyConfigSection 中的其他部分

    <MyConfigSection username="release" password="re1eas3" xdt:Transform="SetAttributes(username, password)" />
    

    【讨论】:

    • 太好了,我开始认为没有人可以帮忙。谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-15
    • 2015-05-09
    相关资源
    最近更新 更多