title: Autofac delegate factory using func<>
body: <p>I am trying to understand the delegate factory pattern with Autofac. I know how to implement factory using IIndex&lt;> with Keyed() registration, which is explained nicely in here: <a href="https://stackoverflow.com/questions/7522541/configuring-an-autofac-delegate-factory-thats-defined-on-an-abstract-class">Configuring an Autofac delegate factory that&#39;s defined on an abstract class</a></p>
  
  <p>I would like to know if I can create a factory using Func&lt;>, and how would I do the registrations for the following sample:</p>
  
  <pre><code>public enum Service
  {
     Foo,
     Bar
  }
  
  public interface FooService : IService 
  {
     ServiceMethod();
  }
  
  public interface BarService : IService 
  {
     ServiceMethod();
  }
  
  public class FooBarClient
  {
     private readonly IService service;
  
     public FooBarClient(Func&lt;Service, IService&gt; service)
     {
        this.service = service(Service.Foo);
     }
  
     public void Process()
     {
        service.ServiceMethod(); // call the foo service.
     }
  }
  </code></pre>