title: Passing the type of the dependent object to the dependency in unity
body: <p>I'm using Unity for dependency injection.  I want to be able to inject my logger into all classes that depend on it.  My problem is that they logger has a constructor argument that needs the <code>Type</code> of the object that's referencing it.  If I were using Ninject, I'd use the <a href="https://github.com/ninject/ninject.extensions.logging/wiki" rel="nofollow">Logging extension</a>.  How would I do the same in Unity?</p>
  
  <p>Here's some sample code to show exactly what I mean.</p>
  
  <pre><code>public class Service1:IService1
  {
      private ILog _log;
      public Service1(ILog log)
      {
          _log = log;
      }
  
      public void DoSomething()
      {
          _log.Print();
      }
  }
  
  public class Service2:IService2
  {
      private ILog _log;
      public Service2(ILog log)
      {
          _log = log;
      }
  
      public void DoSomething()
      {
          _log.Print();
      }
  }
  
  public class Log:ILog
  {
      private Type _ownerType;
      public Log(Type ownerType)
      {
          _ownerType = ownerType;
      }
  
      public void Print()
      {
          Console.Writeline("Owner:  {0}", _ownerType.Name);
      }
  }
  
  unityContainer.RegisterType&lt;IService1, Service1&gt;();
  unityContainer.RegisterType&lt;IService2, Service2&gt;();
  unityContainer.RegisterType&lt;ILog, Log&gt;()  // This is wrong
  
  var s1 = unityContainer.Resolve&lt;IService1&gt;();
  var s2 = unityContainer.Resolve&lt;IService2&gt;();
  
  s1.DoSomething(); // Should print "Owner:  Service1"
  s2.DoSomething(); // Should print "Owner:  Service2"
  </code></pre>