title: Autofac constructor chaining
body: <p>How would I implement the equivalent using Autofac to output <code>123</code>.</p>
  
  <p>I've had a look at the following but I don't think it quite fits in with what I'm trying to achieve.</p>
  
  <p><a href="http://docs.autofac.org/en/latest/advanced/adapters-decorators.html" rel="nofollow">http://docs.autofac.org/en/latest/advanced/adapters-decorators.html</a></p>
  
  <p>Maybe someone can enlighten me - is this <em>decorator</em>?</p>
  
  <pre><code>using System;
  
  namespace Prototypes.Decorator
  {
      public class Program
      {
          static void Main()
          {
              new Class1(new Class2(new Class3(null))).Do();
  
              Console.ReadKey(true);
          }
      }
  
      public interface ICommand
      {
          void Do();
      }
  
      public abstract class BaseClass : ICommand
      {
          private readonly ICommand _command;
  
          protected BaseClass(ICommand command)
          {
              _command = command;
          }
  
          public abstract void Do();
  
          public void CallNext()
          {
              if (_command != null)
              {
                  _command.Do();
              }
          }
      }
  
      public class Class1 : BaseClass
      {
          public Class1(ICommand command) : base(command)
          {
          }
  
          public override void Do()
          {
              Console.Write(1);
  
              CallNext();
          }
      }
  
      public class Class2 : BaseClass
      {
          public Class2(ICommand command) : base(command)
          {
          }
  
          public override void Do()
          {
              Console.Write(2);
  
              CallNext();
          }
      }
  
      public class Class3 : BaseClass
      {
          public Class3(ICommand command) : base(command)
          {
          }
  
          public override void Do()
          {
              Console.Write(3);
  
              CallNext();
          }
      }
  }
  </code></pre>
  
  <p>For bonus points what if there was another interface on the base constructor. Something plausible like <code>protected BaseClass(ICommand command, ILog log) { ... }</code></p>