private IHandlerBase ResolveCommand(Command Command, CommandDispatcher dispatcher, Type type) { var context = new ChildKernel(_kernel); // long-lived context.BindInstance(dispatcher); context.BindInstance(dispatcher.Environments); context.BindInstance(dispatcher.State); context.BindInstance(dispatcher.Output); context.BindInstance(dispatcher.Parser); context.BindInstance(dispatcher.Handlers); // transient context.BindInstance(Command); context.BindInstance(Command.Arguments); if (dispatcher.Environments.Current != null) { context.Bind(dispatcher.Environments.Current.GetType()).ToConstant(dispatcher.Environments.Current); } var instance = context.Get(type); context.Dispose(); return(instance as IHandlerBase); }