| 123456789101112131415161718192021222324252627 |
- using Ninject;
- using System;
- using System.CommandLine;
- namespace CustomHostingDemo
- {
- public class CustomCommand<TArg> : 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<TArg>().ToSelf().InTransientScope();
- kernel.Bind(_handlerType).ToSelf().InTransientScope();
- Handler = new NinjectCommandHandler<TArg>(kernel, _handlerType);
- return this;
- }
- }
- }
|