using Ninject; using System; using System.CommandLine; namespace CustomHostingDemo { public class CustomCommand : Command { private readonly Type _handlerType; public CustomCommand(string name, string description, Type handler) : base(name, description) { _handlerType = handler; } public Command Bind(IKernel kernel) { kernel.Bind().ToSelf().InTransientScope(); kernel.Bind(_handlerType).ToSelf().InTransientScope(); Handler = new NinjectCommandHandler(kernel, _handlerType); return this; } } }