title: Singleton with parameters and Lazy<Singleton>
body: <p>I have an issue with the new <code>Lazy</code> in .NET 4.0. I don't understand how to pass some application parameters at init.</p>
  
  <p>This basic code is working well:</p>
  
  <pre><code>private static readonly Lazy&lt;FactoryHospitalisation&gt; lazy =
      new Lazy&lt;FactoryHospitalisation&gt;(() =&gt; new FactoryHospitalisation();
  
  public static FactoryHospitalisation Instance { get { return lazy.Value; } }
  
  private FactoryHospitalisation()
  {
  }
  </code></pre>
  
  <p>But I don't know how to update the lambda expression when I try to add some parameters, as in this following example:</p>
  
  <pre><code>private string _appId;
  private string _siteCode;
  
  private static readonly Lazy&lt;FactoryHospitalisation&gt; lazy =
      new Lazy&lt;FactoryHospitalisation&gt;(() =&gt; new FactoryHospitalisation("""" What kind of parameters go here ?? """"));
  
  public static FactoryHospitalisation Instance { get { return lazy.Value; } }
  
  private FactoryHospitalisation(string appId, string siteCode)
  {
      _appId = appId;
      _siteCode = siteCode;
  }
  </code></pre>
  
  <p>I know how to do this using the old thread safe with lock version, but it would be very cool to understand how to implement the new 4.0 patterns :)</p>
  
  <p>EDIT: this class is to <code>BindModelToData</code> and reverse (EF to Model and Model to EF). I need to call some object from WCF, and WCF needs to have my application Id and site code to be correctly called.</p>
  
  <p>I have tried to transform <code>Instance</code> in methods, but I don't know if it's correct.</p>
  
  <pre><code>private static string _appId;
  private static string _siteCode;
  
  private static readonly Lazy&lt;FactoryHospitalisation&gt; lazy =
      new Lazy&lt;FactoryHospitalisation&gt;(() =&gt; new FactoryHospitalisation());
  
  public static FactoryHospitalisation Instance(string appId, string siteCode)
  {
      _appId = appId;
      _siteCode = siteCode;
  
      return lazy.Value;
  }
  
  private FactoryHospitalisation()
  {
  }
  </code></pre>