Integrated Solutions, Inc.

Multiple configuration section for different developers

Building on my last post Custom Configuration section….

We often have multiple developers working on the same project but want to be running under different configurations. We do this by adding their machine name to custom config section and replacing the static constructor of the custom config section:

    static Configuration()
    {
      const string ConfigurationSectionName = "ISI.HAPP.API.Configuration";

      Current = null;
      if (Current == null) Current = (Configuration)(System.Configuration.ConfigurationManager.GetSection(string.Format("{0}.{1}", ConfigurationSectionName, System.Environment.MachineName.ToLower())));
      if (Current == null) Current = (Configuration)(System.Configuration.ConfigurationManager.GetSection(ConfigurationSectionName));
      if (Current == null) throw new Exception(string.Format("Missing {0} Configuration Section", ConfigurationSectionName));
    }

and adding a new config section in the app/web.config:

  <ISI.HAPP.API.Configuration.ronmuth>
    <CompanyName>ISI Ron Muth</CompanyName>
    <Authenication>
      <UseNTPermissions>true</UseNTPermissions>
      <DefaultNTDomain>ISI</DefaultNTDomain>
    </Authenication>
  </ISI.HAPP.API.Configuration.ronmuth>
Published 06/19/2009 by Ron Muth