title: How to override named dependency in Unity
body: <p>please suggest me how to solve the following problem:</p>
  
  <p>I have a class:</p>
  
  <pre><code>public class Module
  {
     public Module(Uri param1, Uri param2)
     {
     }
  }
  </code></pre>
  
  <p>This type is registered in The Unity Container:</p>
  
  <pre><code>container.RegisterInstance&lt;Uri&gt;("uri1", new Uri("http://sample-1.com"));
  container.RegisterInstance&lt;Uri&gt;("uri2", new Uri("http://sample-2.com"));
  
  container.RegisterType&lt;Module&gt;(
         new InjectionConstructor(
               new ResolvedParameter&lt;Uri&gt;("uri1"), 
               new ResolvedParameter&lt;Uri&gt;("uri2")));
  </code></pre>
  
  <p>In this way I'm builded dependency to different constructor parameters to different instances of Uri.</p>
  
  <p>I want override this values while resolving instance of Module.</p>
  
  <p>I can override by type:</p>
  
  <pre><code>container.Resolve&lt;Module&gt;(
               new DependencyOverride(typeof(Uri), new Uri("http://overriden.com")))
  </code></pre>
  
  <p>Also I can override by custructor parameters.</p>
  
  <pre><code>container.Resolve&lt;Module&gt;(
     new ParameterOverride("param1", new Uri("http://param1.org"))
     new ParameterOverride("param2", new Uri("http://param2.com")))
  </code></pre>
  
  <p>BUT: I don't know how to override by type according to name of type registration.
  So, DependencyOverride doesn't have any additional parameters for overriding not all types and cannot use named registrations.</p>
  
  <p>Therefore, I would like have something like the following:</p>
  
  <pre><code>container.Resolve&lt;Module&gt;(
      new DependencyOverride("uri1", typeof(Uri), new Uri("http://overriden-1.com")),
      new DependencyOverride("uri2", typeof(Uri), new Uri("http://overriden-2.com")));
  </code></pre>
  
  <p>Where the first parameter (uri1 &amp; uri2) is the names that was used to build dependencies while registering type by using ResolvedParameter("uri1") and ResolvedParameter("uri2") on initial registration.</p>
  
  <p>Please, suggest me, how I can override while resolving Module from a container without defining names of constructor parameters.</p>
  
  <p>P.S. Why do I want go to this way?
  Because I don't want have dependency on name of parameters, someone can rename their and dependency tree will broken. Also, I don't want have dependency of how Module was registered, what kind of constructor was chosen if Module has more than one constructor.</p>
  
  <p>UPD: I found temporarily solution, but it's just workaround, because it broke lifetime managers, for instance PerResolveLifetimeManager due to the fact that we are resolving Module1 and Module2 separately from controller, that have dependency to Module1 and Module2.</p>
  
  <pre><code>        var m1 = _container.Resolve&lt;IModule1&gt;(
              new DependencyOverride(typeof(HttpControllerContext), context),
              new DependencyOverride(typeof(Uri), new Uri("http://module-1.com/")));
  
          var m2 = _container.Resolve&lt;IModule2&gt;(
              new DependencyOverride(typeof(HttpControllerContext), context),
              new DependencyOverride(typeof(Uri), new Uri("http://m-2.com/")));
  
          var dependency = new ResolverOverride[] 
          {
              new DependencyOverride(typeof(HttpControllerContext), context),
              new DependencyOverride(typeof(IModule1), m1),
              new DependencyOverride(typeof(IModule2), m2)
          };
  
          var controller = _container.Resolve(controllerType, dependency) as IHttpController;
          return controller;
  </code></pre>