title: Best way of injecting application configuration
body: <p>Well, I'm making my foray into this fantastic site with a question about the correct way to inject configuration settings into application components.  So, the overview is : I have an application written in C# .Net 3.5.  It consists of 3 assemblies - a Core, a Data and a Service.  The data &amp; service assemblies require settings retrieved from the app.config, which is done via a settings file, eg.</p>
  
  <p>Code :</p>
  
  <pre><code>public static String RequestQueueConnectionString
  {
      get { return ConnectionSettings.Default.RequestQueueConnectionString; }
  }
  </code></pre>
  
  <p>Config :</p>
  
  <pre><code>&lt;applicationSettings&gt;
    &lt;MyNamespace.Data.ConnectionSettings&gt;
      &lt;setting name="RequestQueueConnectionString" serializeAs="String"&gt;
      ...
  </code></pre>
  
  <p>Now, the assemblies are all setup using StructureMap for IoC - which to my mind should provide the answer to what I am looking for, but I just can't quite see it!  </p>
  
  <p>IoC :</p>
  
  <pre><code>public static void ConfigureStructureMap(IContainer container)
  {
      container.Configure(x =&gt; ...
      ...
  </code></pre>
  
  <p>What I want to be able to do is to inject a configuration class already populated into the IoC container such that those settings are used for that assembly, NOT those specified in the settings file / app.config.  So perhaps :</p>
  
  <pre><code>public static void ConfigureStructureMap(IContainer container, MyConfigClass config)
  {
      container.Configure(x =&gt; x.For&lt;DataConfig&gt;()
                                .Singleton()
                                .Use ???
      ...
  </code></pre>
  
  <p>I hope I have provided enough details here - forgive a newbie if I have not and please let me know what else would be helpful in answering this!</p>