以聪明的方式进行Web.config转换

时间:2014-10-02 14:33:43

标签: c# asp.net wcf configuration

我的web.config中有以下客户端端点,我们的地理位置上有生产服务器,例如美国,欧洲,亚洲等都有自己的基地uri。

e.g。 web.config如下所示

<client>
  <endpoint address="http://localhost:9000/ServiceA.svc" binding="wsHttpBinding" contract="IServiceA" name="ServiceA"></endpoint>
  <endpoint address="http://localhost:9000/ServiceB.svc" binding="wsHttpBinding" contract="IServiceA" name="ServiceB"></endpoint>
  <endpoint address="http://localhost:9000/ServiceC.svc" binding="wsHttpBinding" contract="IServiceA" name="ServiceC"></endpoint>
  <endpoint address="http://localhost:9000/ServiceD.svc" binding="wsHttpBinding" contract="IServiceA" name="ServiceD"></endpoint>
  <endpoint address="http://localhost:9000/ServiceE.svc" binding="wsHttpBinding" contract="IServiceA" name="ServiceE"></endpoint>

对于Ameria地区,我有Web.America.config但它应该转换为

    <client>
        <endpoint xdt:Transform="SetAttributes(address)" xdt:Locator="Match(name)" address="http://localhost:9000/america/ServiceA.svc" name="ServiceA"></endpoint>
        <endpoint xdt:Transform="SetAttributes(address)" xdt:Locator="Match(name)" address="http://localhost:9000/america/ServiceB.svc" name="ServiceB"></endpoint>

... ...

但我不希望这种重复,因为我只需要更改基地址。有没有更好的方法呢?

0 个答案:

没有答案