title: Dependency Injection - passing parameters to constructed types
body: <p>I'm introducing Dependency Injection to my project. I've got a dialog window, which serves as an editor to either new or existing entity. Its ViewModel looks like the following:</p>
  
  <pre><code>public class ContractWindowViewModel
  {
      private IRepository&lt;Contract&gt; contractRepository;
      private Contract model;
      private bool isNew;
  
      public ContractWindowViewModel(Contract contract, IRepository&lt;Contract&gt; contractRepository)
      {
          if (contract == null)
              throw new ArgumentNullException(nameof(contract));
          if (contractRepository == null)
              throw new ArgumentNullException(nameof(contractRepository));
  
          this.contractRepository = contractRepository;
          this.model = contract;
          this.isNew = false;
      }
  
      public ContractWindowViewModel(IRepository&lt;Contract&gt; contractRepository)
      {
          this.contractRepository = contractRepository;
          this.model = new Contract();
          this.isNew = true;
      }
  
      // (...)
  }
  </code></pre>
  
  <p>The plan is to inject <code>IRepository&lt;Contract&gt;</code>. But sometimes I need to pass <code>Contract</code> to the ViewModel (if I want to edit an existing one) or not (if I want to create new one). How should I do that using Unity?</p>