コード例 #1
0
        public KernelServer(
            Kernel kernel,
            IInputTextStream input,
            IOutputTextStream output,
            DirectoryInfo workingDir)
        {
            _kernel = kernel ?? throw new ArgumentNullException(nameof(kernel));
            _input  = input ?? throw new ArgumentNullException(nameof(input));
            _output = output ?? throw new ArgumentNullException(nameof(output));

            if (workingDir is null)
            {
                throw new ArgumentNullException(nameof(workingDir));
            }

            _disposables = new CompositeDisposable
            {
                _input.Subscribe(async line =>
                {
                    await DeserializeAndSendCommand(line);
                }),
                _kernel.KernelEvents.Subscribe(WriteEventToOutput),
                _input
            };

            Environment.CurrentDirectory = workingDir.FullName;
            WriteEventToOutput(new KernelReady());
        }
コード例 #2
0
ファイル: KernelStreamClient.cs プロジェクト: yamachu/try
        public KernelStreamClient(IKernel kernel, IInputTextStream input, IOutputTextStream output)
        {
            _disposables = new CompositeDisposable();
            _kernel      = kernel ?? throw new ArgumentNullException(nameof(kernel));
            _input       = input ?? throw new ArgumentNullException(nameof(input));
            _output      = output ?? throw new ArgumentNullException(nameof(output));
            _disposables.Add(
                _input.Subscribe(async line => { await ParseLine(line); }));
            _disposables.Add(
                _kernel.KernelEvents.Subscribe(e =>
            {
                switch (e)
                {
                case KernelBusy _:
                case KernelIdle _:
                    break;

                default:
                    {
                        var id = (int)e.GetRootCommand().Properties["id"];
                        Write(e, id);
                    }
                    break;
                }
            }));
        }
コード例 #3
0
        public KernelClient(
            IInputTextStream input,
            IOutputTextStream output)
        {
            _input  = input ?? throw new ArgumentNullException(nameof(input));
            _output = output ?? throw new ArgumentNullException(nameof(output));

            _disposables = new CompositeDisposable
            {
                _input.Subscribe(DeserializeAndSendEvent)
            };
        }