title: ServiceLocator pattern with autofac
body: <p>How can we implement a ServiceLocator class with Resolve() method inside it using Autofac. We need to implement it in Asp.net core project and a console application.</p>
  
  <p>We are facing two challenges:</p>
  
  <ul>
  <li><p>We cannot simply return a class instance as it needs to be created using lifetime scope and lifetime scope should be disposed after instance usage. So we will have to return Lifetimescope or any abstraction over it, which is not intuitive.</p></li>
  <li><p>In context of asp.net core, we will have to create a different lifetimescope, we want to utilize lifetime scope created by .net core itself.</p></li>
  </ul>
  
  <p>Thanks</p>