title: Unity - RegisterFactory vs RegisterInstance
body: <p>I'm new to Unity Containers but have some experience with IoC/DI, and whilst wiring a <code>ServiceClientFactory</code> I ended up with 2 ways to register a singleton for it:</p>
  
  <pre><code>// register factory singleton
  var factory = new ServiceClientFactory(strategy);
  container.RegisterInstance&lt;IServiceClientFactory&gt;(factory, InstanceLifetime.Singleton);
  
  // register factory factory for the singleton
  container.RegisterFactory&lt;IServiceClientFactory&gt;((x) =&gt; new ServiceClientFactory(strategy), FactoryLifetime.Singleton);
  </code></pre>
  
  <p>I've tested both versions with unit tests and both validate and work as expected, I'm not evaluating speed yet, so I suspect <code>RegisterFactory</code> may work under the hood differently.</p>
  
  <p>When should one use one or the other? Is there a significant overhead by using <code>RegisterFactory</code>? </p>
  
  <p>Which would be recommended for this case? <code>strategy</code> is just a local function that resolves factory expected types from the <code>IUnityContainer</code>.</p>
  
  <p>I'd like to keep the factory container agnostic if we decide to go with another IoC library, or eventually use <code>IServiceCollection</code> too.</p>