title: Resolving named services in DryIoc DI-Container
body: <p>Consider the following two classes:</p>
  <pre><code>public class Number
  {
      public int Value { get; set; }
  }
  
  public class Multiplier
  {
      private readonly Number first;
      private readonly Number second;
  
      public Multiplier(Number first, Number second)
      {
          this.first = first;
          this.second = second;
      }
  
      public int Multiply() =&gt; this.first.Value * this.second.Value;
  }
  </code></pre>
  <p>The class <em>Multiplier</em> depends on two instances of <em>Number</em>. I want to inject both of them as <em>named services</em> using a DryIoc DI-Container. The code to do this looks like this:</p>
  <pre><code>var container = new Container();
  
  container.RegisterInstance(new Number{Value = 2}, serviceKey:&quot;first&quot;);
  container.RegisterInstance(new Number{Value = 4}, serviceKey:&quot;second&quot;);
  container.Register&lt;Multiplier&gt;();
  
  var consumer = container.Resolve&lt;Multiplier&gt;();
  
  Console.WriteLine(consumer.Multiply());
  </code></pre>
  <p>This code fails with a <em>DryIoc.ContainerException</em> (when calling <em>Resolve</em>) since the registered instances can not be resolved to the constructor arguments. My question basically is: Is there any way that allows me to specify which named <em>serviceKey</em> should be resolved to which constructor argument?</p>
  <p>In MEF I would do the following to achieve this:</p>
  <pre><code>[Export(typeof(Multiplier))]
  public class Multiplier
  {
      private readonly Number first;
      private readonly Number second;
  
      [ImportingConstructor]
      public Multiplier([Import(&quot;first&quot;)]Number first, 
                        [Import(&quot;second&quot;)]Number second)
      {
          this.first = first;
          this.second = second;
      }
  
      public int Multiply() =&gt; this.first.Value * this.second.Value;
  }
  </code></pre>
  <p>and then export the dependencies using the service names:</p>
  <pre><code>var container = new CompositionContainer(someCatalog);
  container.ComposeExportedValue(&quot;first&quot;, new Number{Value = 2});
  container.ComposeExportedValue(&quot;second&quot;, new Number{Value = 4});
  
  var multi = container.GetExport&lt;Multiplier&gt;();
  </code></pre>
  <p>How can I do this using DryIoc?</p>