title: Resolve type with IoC Container from within static Method
body: <p>When using an IoC container without a static container instance (as this would result in a a service locator anti-pattern), how to resolve types from a static method?</p>
  
  <p>Say, I have a method that reads an object <code>Document</code> from a file:</p>
  
  <pre><code>public class Document {
      // when used with IoC, the Logger gets injected via property injection
      public ILogger Logger { get; set; }
      /* ... */
      public static Document Read (string filePath)
      {
          // need to resolve an ILogger at this point?
          Logger.Info ("reading in {0}", filePath);
  
          /* ...read in document an return a document instance here ... */
  
      }
  }
  </code></pre>
  
  <p>The Code is C# but same problem would apply to a Java project.</p>
  
  <p>I know that a simple answer would be "don't use static method", but given the method is stateless i think it is one of the cases where static methods make sense.</p>
  
  <p>Having a singleton IoC container would also help, but this is widely known to be an anti-pattern.</p>
  
  <p>So, what is the way out of the problem?</p>