插入带的Web.Config变换多个项目 [英] Inserting multiple items with Web.Config transforms

查看:107
本文介绍了插入带的Web.Config变换多个项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个引用了大量的WCF服务的C#项目。对于本地测试,我想更换身份标签的内容,这样它会接受任何在本地主机上运行。

I've got a C# project that references a lot of WCF services. For local testing, I want to replace the contents of the identity tags so that it will accept anything running on localhost.

以下变换工作,但仅插入在第一匹配位置的DNS元件。所以,如果我5端点引用,一会在DNS标签,而其他人都有空的标识元素。

The following transformation works, but only inserts the dns element in the first matching location. So, if I had 5 endpoints referenced, one would have the dns tag, and the others would all have empty identity elements.

<system.serviceModel>
    <client>
      <endpoint>
        <identity>
          <dns xdt:Transform="Insert" value="localhost"/>
          <userPrincipalName xdt:Transform="RemoveAll" value="someIdentity" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>

如何改变所有的匹配元件,而不仅仅是第一λ

How do I alter all of the matching elements, not just the first?

推荐答案

使用 XDT:定位属性来定义一个XPath前pression匹配所有&LT;身份方式&gt; 要插入的元素

Use the xdt:Locator attribute to define an XPath expression to match all <identity> elements that you want to insert into.

  <system.serviceModel>
    <client>
      <endpoint>
        <identity xdt:Locator="XPath(//identity)">
          <dns xdt:Transform="Insert" value="localhost"/>
          <userPrincipalName xdt:Transform="RemoveAll"/>
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>

这篇关于插入带的Web.Config变换多个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆