title: How to use a lambda to specify a constructor argument?
body: <p>I am not overly familiar with implementing lambdas and expressions, but I've used to this syntax many times in MVC where the lambda is identifying a property on an object:</p>
  
  <pre><code>Html.Label(model =&gt; model.Foo)
  </code></pre>
  
  <p>In my app I am using Ninject conditional bindings to supply the instance of the <code>Settings</code> class which is injected when I request an instance of <code>Class</code>.  My <code>Class</code> looks like this:</p>
  
  <pre><code>public class Class
  {
      private readonly Settings settings;
  
      public Settings Settings { get { return settings; } }
  
      public Class(Settings settings)
      {
          this.settings = settings;
      }
  }
  </code></pre>
  
  <p>I have some code which looks like this to get an instance of <code>Class</code>.  I am aware this is the <a href="http://blog.ploeh.dk/2010/02/03/ServiceLocatorisanAnti-Pattern/" rel="nofollow">service locator anti pattern</a>, but we have no choice in this case due to other constraints:</p>
  
  <pre><code>var settings = new Settings();
  var instance = Ioc.Instance.Get&lt;Class&gt;("settings", settings);
  </code></pre>
  
  <p>I would like to refactor it to look like this so that it is strongly typed, using a lambda to specify which argument on the constructor I am supplying: </p>
  
  <pre><code>var settings = new Settings();
  var instance = Ioc.Instance.Get&lt;Class&gt;(x =&gt; x.settings, settings);
  </code></pre>
  
  <p>So, is this possible, and what would the code look like?</p>