This project is read-only.

#remove - feature

Dec 10, 2010 at 6:50 PM
Edited Dec 10, 2010 at 6:58 PM

A nice feature in the \samples\binding is that you can remove a config setting.

I'm just posting this here because there's not a lot of online doc, and it's harder to find this unless you download the samples and open each one and analyze it.

${Xpath=/configuration/appSettings/add[@key ='SomeSwitchToCompletelyRemove']}

with the value #remove in the target environment column. 

 

Another example:

${Xpath=//SomePlaceholder}

can be replaced with xml, by putting some value like this in the target environment column:

<SomeXML Foo="bar"/>

By combining these two, you should be able to have some XML chunks exist on one environment, and not on others.

INPUT:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
 
  <appSettings>
    <add
      key="SomeSwitch"
      value="False"/>
    <add
      key="SomeSwitchToCompletelyRemove"
      value="False"/>
  </appSettings>
 
  <connectionStrings>
    <!-- This will connect to the @environment@ database -->
    <add
      name="LocalSqlServer"
      connectionString="Database=db;Server=local;Integrated Security=SSPI;MultipleActiveResultSets=true;"
      providerName="System.Data.SqlClient" />
  </connectionStrings>

  <system.web>
    <compilation
      debug="true"/>
   
    <SomePlaceholder/>

  </system.web>
 
</configuration>

 

OUTPUT:

 

<?xml version="1.0" encoding="utf-8"?>
<configuration>
 
  <appSettings>
    <add
      key="SomeSwitch"
      value="True" />
   
  </appSettings>
 
  <connectionStrings>
    <!-- This will connect to the Production database -->
    <add
      name="LocalSqlServer"
      connectionString="Database=db;Server=productionserver;Integrated Security=SSPI;"
      providerName="System.Data.SqlClient" />
  </connectionStrings>

  <system.web>
    <compilation
      debug="true" />
   
    <SomePlaceholder><SomeXML
        Foo="bar" /></SomePlaceholder>

  </system.web>
 
</configuration>

 

Neal