title: Can Autofac do automatic self-binding?
body: <p>I know some DI frameworks support this (e.g. <a href="http://ninject.org/" rel="noreferrer">Ninject</a>), but I specifically want to know if it's possible with <a href="http://code.google.com/p/autofac/" rel="noreferrer">Autofac</a>.</p>
  
  <p>I want to be able to ask an Autofac container for a concrete class, and get back an instance with all appropriate constructor dependencies injected, <strong>without ever registering that concrete class.</strong> I.e., if I never bind it explicitly, then <em>automatically</em> bind the concrete class to itself, as if I had called <code>builder.Register&lt;MyClass&gt;();</code></p>
  
  <p>A good example of when this would be useful is ViewModels. In MVVM, the layering is such that only the View depends on the ViewModel, and that via loose typing, and you don't unit-test the View anyway. So there's no need to mock the ViewModel for tests -- and therefore there's no reason to have an interface for each ViewModel. So in this case, the usual DI pattern of "register this interface to resolve to this class" is unnecessary complexity. Explicit self-binding, like <code>builder.Register&lt;MyClass&gt;();</code>, also feels like an unnecessary step when dealing with something as straightforward as a concrete class.</p>
  
  <p>I'm aware of the <a href="http://code.google.com/p/autofac/wiki/ExtendingContainerBuilder" rel="noreferrer">reflection-based registration example</a> in the Autofac docs, but that's not to my taste either. I don't want the complexity (and slowness) of registering every possible class ahead of time; I want the framework to give me what I need when I need it. Convention over configuration, and all that.</p>
  
  <p>Is there any way to configure Autofac so it can say "Oh, this is a concrete type, and nobody registered it yet, so I'll just act like it had been registered with default settings"?</p>