slow-cheetah icon indicating copy to clipboard operation
slow-cheetah copied to clipboard

Can I replace part of a value?

Open MrYossu opened this issue 8 years ago • 4 comments

All of the examples I've seen of using SlowCheetah involve replacing the full contents of an attribute in a node.

What I want to do is replace part of an attribute value. For example, if my App.config file contains the following...

  <endpoint address="http://localhost:24953/Services/AuditService.svc"
            binding="customBinding"
            bindingConfiguration="CustomBindingDefault"
            contract="AuditServiceReference.AuditService"
            name="AuditService" />

...then I can add a transform to my App.Release.config file as follows...

  <endpoint address="http://www.mydomain.co.uk/Services/AuditService.svc"
            behaviorConfiguration="LargeMessageBehavior"
            binding="customBinding"
            bindingConfiguration="CustomBindingDefault"
            contract="AuditServiceReference.AuditService"
            name="AuditService"
            xdt:Transform="Replace"
            xdt:Locator="Match(name)" />

...and it will produce the correct output.

However, as I have a lot of these service references, I have lots of entries like the above in the App.config file, with corresponding entries in the App.Release.config file.

What I would really like to do is only have to add one entry to the App.Release.config file that works all of the service entries in the App.config file, ie it transforms localhost:24953 into www.mydomain.co.uk for each node in the file.

Is this possible, or do I have to have a separate entry in my App.Release.config file for every service?

MrYossu avatar Dec 22 '16 16:12 MrYossu

Anyone?

MrYossu avatar Jan 30 '17 19:01 MrYossu

65197903

todthomson avatar Jan 30 '17 22:01 todthomson

SlowCheetah uses Microsoft.Web.Xdt to process the XML transforms. Here is the MSDN page for it. I believe the SetAttributes section is what you are looking for.

jviau avatar Jan 30 '17 23:01 jviau

Replacing a portion of the value is not supported with XDT out of the box. It is possible to create a custom XDT transform which can replace a portion of an attribute value. I describe how to do this in an old blog post at http://sedodream.com/2010/09/09/extendingxmlwebconfigconfigtransformation.aspx.

With that said, I've never tested using a custom transform with SlowCheetah. Also @jviau and others are in the middle of refactoring the code, so if you get it working now you may need to update a reference later.

sayedihashimi avatar Jan 30 '17 23:01 sayedihashimi