title: Unity container, resolve to an abstract class level and not top Interface
body: <p>I have the following code defined in terms of hierarchy - </p>
  
  <pre><code>public interface ISomeInterface
      {
          bool DoSomething();
      }
  
      public abstract class AbsActualWorker : ISomeInterface
      {
          public bool DoSomething()
          {
              Console.WriteLine("DoSomething");
              throw new Exception("throwing exception for the sake of it!");
          }
  
          public abstract bool DoSomething2();
      }
  
      public class ActualWorker : AbsActualWorker
      {
          public override bool DoSomething2()
          {
              Console.WriteLine("DoSomething2");
              Thread.Sleep(1000);
              return true;
              //throw new Exception("throwing exception for the sake of it!");
          }
      }
  </code></pre>
  
  <p>Im trying to resolve to the <code>ActualWorker</code> level and execute its <code>DoSomething2</code></p>
  
  <pre><code>var container = new UnityContainer();
  container.AddNewExtension&lt;Interception&gt;();
  container.RegisterType&lt;AbsActualWorker, ActualWorker&gt;();
  container
              .RegisterType&lt;ISomeInterface, ActualWorker&gt;(new Interceptor(new InterfaceInterceptor()),
                                                                              new InterceptionBehavior(new MyLoggerBehavior())
                                                             );
  var instance = container.Resolve&lt;ISomeInterface&gt;();
  if (instance != null)
  {
      instance.DoSomething();
  }
  </code></pre>
  
  <p>Code happily resolves and can call </p>
  
  <pre><code>instance.DoSomething();
  </code></pre>
  
  <p>When I cast instance to <code>ActualWorker</code> Im getting null. Id like to use call <code>DoSomething2</code>.</p>
  
  <pre><code>public class MyLoggerBehavior : IInterceptionBehavior
      {
          public IMethodReturn Invoke(IMethodInvocation input, GetNextInterceptionBehaviorDelegate getNext)
          {
              var returnValue = getNext()(input, getNext);
  
              if (returnValue.Exception != null)
              {
                  Console.WriteLine("Exception occurred!!");
              }
              else
              {
                  Console.WriteLine("Method {0} returned {1}", input.MethodBase, returnValue.ReturnValue);
              }
              return returnValue;
          }
  
          public IEnumerable&lt;Type&gt; GetRequiredInterfaces()
          {
              return Type.EmptyTypes;
          }
  
          public bool WillExecute
          {
              get { return true; }
          }
      }
  </code></pre>