title: Equivalent Simple Injector .Register invocations
body: <p>I have an object whose constructor requires a primitive. I register it using a delegate (please excuse the contrived example).</p>
  <pre class="lang-cs prettyprint-override"><code>container.Register&lt;Account&gt;(() =&gt; new Account(1000M), Lifestyle.Singleton);
  </code></pre>
  <p>I register this type <code>Account</code> as the implementation of an interface <code>IAccount</code>. When doing so using the call marked <code>B</code> below, SimpleInjector's <code>.Verify()</code> complains:</p>
  <pre class="lang-cs prettyprint-override"><code>/* B */container.Register&lt;IAccount, Account&gt;(Lifestyle.Singleton);
  </code></pre>
  <blockquote>
  <p>The constructor of type Account contains parameter 'funds'
  of type decimal, which can not be used for constructor injection
  because it is a value type. (Parameter 'TImplementation')</p>
  </blockquote>
  <p>Using the call marked <code>A</code> instead has no such issues and works as intended:</p>
  <pre class="lang-cs prettyprint-override"><code>/* A */container.Register&lt;IAccount&gt;(() =&gt; container.GetInstance&lt;Account&gt;(), Lifestyle.Singleton);
  </code></pre>
  <p>I seem to have incorrectly assumed that <code>A</code> and <code>B</code> would be <em>effectively</em> equivalent. What have I missed? Why does <code>B</code> fail to utilise the registered delegate for creation of the <code>Account</code> instance? Thank you.</p>
  <p>(File below is LINQPad (.linq) format)</p>
  <pre class="lang-cs prettyprint-override"><code>&lt;Query Kind=&quot;Program&quot;&gt;
    &lt;NuGetReference&gt;SimpleInjector&lt;/NuGetReference&gt;
    &lt;Namespace&gt;SimpleInjector&lt;/Namespace&gt;
  &lt;/Query&gt;
  
  void Main()
  {
      var containerRegistry = new ContainerRegistry();
      Console.WriteLine(&quot;Balance = &quot; + containerRegistry.GetInstance&lt;Account&gt;().Balance);
  }
  
  public class ContainerRegistry
  {
      private readonly Container container = new Container();
  
      public ContainerRegistry()
      {
          container.Register&lt;Account&gt;(() =&gt; new Account(1000M), Lifestyle.Singleton);
  
          /* A */container.Register&lt;IAccount&gt;(() =&gt; container.GetInstance&lt;Account&gt;(), Lifestyle.Singleton);
          /* B */container.Register&lt;IAccount, Account&gt;(Lifestyle.Singleton);
  
          container.Verify();
      }
      
      [Obsolete] public TInstanceType GetInstance&lt;TInstanceType&gt;() where TInstanceType : class
          =&gt; container.GetInstance&lt;TInstanceType&gt;();
  }
  
  public class Account : IAccount
  {
      public decimal Balance =&gt; funds;
      
      private readonly decimal funds;
      
      public Account(decimal funds)
      {
          this.funds = funds;
      }
  }
  
  public interface IAccount
  {
      decimal Balance { get; }
  }
  </code></pre>