title: Dependency Injection of configuration class into static Document DB repository (VS2015 DNX project)
body: <p>I have a base Document DB repository in the infrastructure layer of my solution.  I based this repository on <a href="https://github.com/Azure/azure-documentdb-net/blob/master/tutorials/todo/src/DocumentDBRepository.cs" rel="nofollow noreferrer">this GitHub project</a>, which is a static class that is utilized by my other domain model repositories.</p>
  
  <p>In my API layer I have config.json files that are environment specific. I would like to use dependency injection to be able to use my configuration class that reads the DocumentDB settings defined in the API layer in the deeper Infrastructure layer.  <a href="https://stackoverflow.com/questions/27179370/using-iconfiguration-globally-in-mvc6">This StackOverflow answer</a> details how to use DI with an API controller, however I can't figure out how to use DI in this case, as a static class, I don't have a constructor.  Is it possible to use DI with my static repository?  If not, how should I read config settings into the infrastructure layer?</p>
  
  <p><strong>My ConfigurationOptions class (in Infrastructure layer):</strong></p>
  
  <pre><code>public class ConfigurationOptions
  {
      public string EndpointUri { get; set; }
  }
  </code></pre>
  
  <p><strong>My DocumentDbRepository class (in Infrastructure layer):</strong></p>
  
  <pre><code>public static class DocumentDbRepository&lt;T&gt;
  {
      // I want to read these strings from my config.json files
      private static string EndpointUri { get; } = ConfigurationOptions.EndpointUri;
  
      //...
  
  
      private static Document GetDocument(string id)
      {
          return Client.CreateDocumentQuery(Collection.DocumentsLink)
              .Where(d =&gt; d.Id == id)
              .AsEnumerable()
              .FirstOrDefault();
      }
  }
  </code></pre>
  
  <p><strong>Part of my Startup class (in my API layer)</strong></p>
  
  <pre><code>public class Startup
  {
      public IConfiguration Configuration { get; set; }
  
      public void ConfigureServices(IServiceCollection services)
      {
          services.Configure&lt;ConfigurationOptions&gt;(options =&gt;
              options.EndpointUri = Configuration.Get("EndpointUri"));
  
      // ...
  
      }
  
  // ...
  
  }
  </code></pre>