title: Replace Ninject with .NET Core built-in DI with typed parameters
body: <p>I have an old .NET application that uses Ninject to resolve an instance of an ICommandHandler as shown below. I also uses the Db context to call SaveChanges(). I'm now trying to convert this code so that I can use it in a new .NET Core application with its built-in Dependency Injection.</p>
  
  <pre><code>    public class CommandInvoker : ICommandInvoker
      {
          private readonly IKernel _kernel;
          private readonly IArhomaContext _context;
  
          public CommandInvoker(IKernel kernel, IArhomaContext context)
          {
              _kernel = kernel;
              _context = context;
          }
  
          public void Execute&lt;T&gt;(T command)
          {
              var handler = _kernel.TryGet&lt;ICommandHandler&lt;T&gt;&gt;();
              handler.Handle(command);
              _context.SaveChanges();
          }
      }
  </code></pre>
  
  <p>I'm thinking that I have to add the following to the ConfigureServices method in Startup.cs:</p>
  
  <pre><code>services.AddScoped&lt;ICommandHandler, CommandHandler&gt;();
  </code></pre>
  
  <p>But ICommandHandler has a typed parameter. How is that done or registered?</p>
  
  <p>Secondly, I need to resolve it to create a handler that executes the command. How does one resolve this in .NET Core?</p>
  
  <p>P.S. I do not want to continue using Ninject in my .NET Core app.</p>