title: How to create instance of a class and inject services?
body: <p>New aspnet has in-build dependency injection: Startup class instance receives services, controllers, view components do. Is there any way for me to create object of my class and pass services using aspnet functionality? Something like:</p>
  
  <pre><code>WebApplicationClassesActivator.Create(typeof(MyClass))
  </code></pre>
  
  <p>where <code>MyClass</code> contains constructor receiving <code>IHostingEnvironment</code> instance, for example.</p>
  
  <p>Real usage:</p>
  
  <pre><code>public class MyController : Controller
  {
      private readonly IContext Context;
      public MyController(IContext context)
      {
          Context = context;
      }
      public IActionResult Index(string className)
      {            
          return View(WebApplicationClassesActivator.Create(Type.GetType(className)));
      }
  }
  </code></pre>
  
  <p>Where <code>classsName</code> is name of classes like:</p>
  
  <pre><code>public class A
  {
      public A(IContext context, IHostingEnvironment env)
      {
         ...
      }
  }
  </code></pre>