title: How do I register a delegate or function with Autofac when the function belongs to a class that must be resolved?
body: <p>I'm using Autofac. I want to inject a delegate into a class:</p>
  
  <pre><code>public delegate ValidationResult ValidateAddressFunction(Address address);
  
  public class OrderSubmitHandler
  {
      private readonly ValidateAddressFunction _validateAddress;
  
      public OrderSubmitHandler(ValidateAddressFunction validateAddress)
      {
          _validateAddress = validateAddress;
      }
  
      public void SubmitOrder(Order order)
      {
          var addressValidation = _validateAddress(order.ShippingAddress);
          if(!addressValidation.IsValid)
              throw new Exception("Your address is invalid!");
      }
  }
  </code></pre>
  
  <p>The implementation of <code>ValidateAddressFunction</code> I want to inject comes from a class that must be resolved from the container because it has dependencies of its own:</p>
  
  <pre><code>public class OrderValidator
  {
      private readonly ISomeDependency _dependency;
  
      public OrderValidator(ISomeDependency dependency)
      {
          _dependency = dependency;
      }
  
      public ValidationResult ValidateAddress(Address address)
      {
          // use _dependency
          // validate the order
          // return a result
          return new ValidationResult();
      }
  }
  </code></pre>
  
  <p>In this example I'm using a delegate, but I could just as well be injecting <code>Func&lt;Address, ValidationResult&gt;</code>.</p>
  
  <p>I could just inject <code>OrderValidator</code>, but I'd rather not create an interface with just one method. If all my class needs is one method then I'd rather depend directly on that.</p>
  
  <p>How do I register the delegate or <code>Func</code> in such a way that when it's resolved, the class that contains the method will be resolved, and then I can use the method from the resolved instance?</p>