title: Unity Application Block, inherited injection
body: <p>I am having a problem using the Unity Application Block, I have created a base class called Composition.  </p>
  
  <p>Each Composition contains a IUnityContainer, when i create the top level object UniversalComposition i want to initialize it with a UnityContainer.  </p>
  
  <p>Any object that gets created from the UniversalComposition I want to inject a child IUnityContainer into it, using the IUnityContainer.CreateChildContainer method.</p>
  
  <pre><code>class Program
  {
      static void Main(string[] args)
      {
          UniversalComposition universe = new UniversalComposition();
  
  
      }
  }
  
  public class UniversalComposition : Composition
  {
      // Everything that gets resolved in this container should contain a child container created by the this container
  
      public UniversalComposition()
      {
          this.Container.RegisterType&lt;IService, Service&gt;();
      }
  
      protected override IUnityContainer CreateContainer()
      {
          return new UnityContainer();
      }
  
  }
  
  public abstract class Composition
  {
      protected IUnityContainer Container {get; private set;}
  
      public Composition()
      {
          this.Container = this.CreateContainer();
      }
  
      public TInstance Resolve&lt;TInstance&gt;()
      {
          return this.Container.Resolve&lt;TInstance&gt;();
      }
  
      protected abstract IUnityContainer CreateContainer();
  }
  
  public class Service : Composition, IService
  {
      public Service(/* I want to inject a child Unity Container in here container.CreateChildContainer() */)
      {
      }
  }
  
  public interface IService { }
  </code></pre>