|
|
@@ -44,23 +44,23 @@ namespace CustomHostingDemo
|
|
|
var parser = new CommandLineBuilder(rootCommand)
|
|
|
.UseMiddleware((invocationContext) =>
|
|
|
{
|
|
|
- //invocationContext.BindingContext.ParseResult.
|
|
|
- //invocationContext.BindingContext.AddService(typeof(IResolutionRoot), () => kernel);
|
|
|
+ var cmdArgs = new HelloCommand.HelloArgs();
|
|
|
+ var binder = new ModelBinder<HelloCommand.HelloArgs>();
|
|
|
+ binder.UpdateInstance(cmdArgs, invocationContext.BindingContext);
|
|
|
+
|
|
|
+ kernel.Bind<HelloCommand.HelloArgs>().ToConstant(cmdArgs).InSingletonScope();
|
|
|
+
|
|
|
+ //invocationContext.BindingContext.AddService(typeof(HelloCommand.HelloArgs), () => cmdArgs);
|
|
|
invocationContext.BindingContext.AddService(typeof(HelloCommand.DefaultHandler), () =>
|
|
|
{
|
|
|
var handler = kernel.Get<HelloCommand.DefaultHandler>();
|
|
|
- var binder = new ModelBinder<HelloCommand.DefaultHandler>();
|
|
|
- binder.UpdateInstance(handler, invocationContext.BindingContext);
|
|
|
return handler;
|
|
|
});
|
|
|
- //invocationContext.BindingContext.AddService(typeof(HelloCommand), () => {
|
|
|
- // return kernel.Get<HelloCommand>();
|
|
|
- //});
|
|
|
})
|
|
|
+ .UseDefaults()
|
|
|
.Build();
|
|
|
|
|
|
- parser.InvokeAsync(args);
|
|
|
- //rootCommand.Invoke(args);
|
|
|
+ parser.InvokeAsync(args).Wait();
|
|
|
}
|
|
|
}
|
|
|
}
|