public async Task InvokeAsync( IKernelCommand command, KernelPipelineContext context) { EnsureMiddlewarePipelineIsInitialized(); await _pipeline(command, context, (_, __) => Task.CompletedTask); }
protected internal override async Task HandleAsync( IKernelCommand command, KernelPipelineContext context) { var kernel = context.Kernel; if (kernel is KernelBase kernelBase) { await kernelBase.SendOnContextAsync(command, context); return; } throw new NoSuitableKernelException(); }
protected internal override async Task HandleAsync( IKernelCommand command, KernelPipelineContext context) { switch (command) { case SubmitCode submitCode: context.OnExecute(async invocationContext => { await HandleSubmitCode(submitCode, invocationContext); }); break; } }
protected override void SetKernel( IKernelCommand command, KernelPipelineContext context) { if (context.Kernel == null) { if (DefaultKernel != null) { context.Kernel = DefaultKernel; } else if (_kernels.Count == 1) { context.Kernel = _kernels[0]; } } }
protected Parser BuildDirectiveParser(KernelPipelineContext pipelineContext) { var root = new RootCommand(); foreach (var c in _directiveCommands) { root.Add(c); } return(new CommandLineBuilder(root) .UseMiddleware( context => context.BindingContext .AddService( typeof(KernelPipelineContext), () => pipelineContext)) .Build()); }
public async Task <IKernelCommandResult> SendAsync( IKernelCommand command, CancellationToken cancellationToken) { if (command == null) { throw new ArgumentNullException(nameof(command)); } var pipelineContext = new KernelPipelineContext(PublishEvent); await SendOnContextAsync(command, pipelineContext); var result = await pipelineContext.InvokeAsync(); return(result); }
private Task ChooseKernel( IKernelCommand command, KernelPipelineContext context, KernelPipelineContinuation next) { if (context.Kernel == null) { if (DefaultKernel != null) { context.Kernel = DefaultKernel; } else if (_kernels.Count == 1) { context.Kernel = _kernels[0]; } } return(next(command, context)); }
protected internal abstract Task HandleAsync( IKernelCommand command, KernelPipelineContext context);
public async Task SendOnContextAsync( IKernelCommand command, KernelPipelineContext invocationContext) { await Pipeline.InvokeAsync(command, invocationContext); }