title: How can I pass a runtime parameter as part of the dependency resolution?
body: <p>I need to be able to pass a connection string into some of my service implementations. I am doing this in the constructor. The connection string is configurable by user will be added the ClaimsPrincipal as a Claim.</p>
  
  <p>All fine so far.</p>
  
  <p>Unfortunately, I also want to be able to use the dependency injection features in ASP.NET Core to the fullest and resolve the service implementation though DI.</p>
  
  <p>I have a POC implmentation: </p>
  
  <pre><code>public interface IRootService
  {
      INestedService NestedService { get; set; }
  
      void DoSomething();
  }
  
  public class RootService : IRootService
  {
      public INestedService NestedService { get; set; }
  
      public RootService(INestedService nestedService)
      {
          NestedService = nestedService;
      }
  
      public void DoSomething()
      {
          // implement
      }
  }
  
  
  public interface INestedService
  {
      string ConnectionString { get; set; }
  
      void DoSomethingElse();
  }
  
  public class NestedService : INestedService
  {
      public string ConnectionString { get; set; }
  
      public NestedService(string connectionString)
      {
          ConnectionString = connectionString;
      }
  
      public void DoSomethingElse()
      {
          // implement
      }
  }
  </code></pre>
  
  <p>These services have been registered during startup and <code>INestedService</code> has been added the constructor of a controller. </p>
  
  <pre><code>public HomeController(INestedService nestedService)
  {
      NestedService = nestedService;
  }
  </code></pre>
  
  <p>As expected, I get the error <code>Unable to resolve service for type 'System.String' while attempting to activate 'Test.Dependency.Services.NestedService'.</code></p>
  
  <p>What are my options here?</p>