public static KernelServer CreateKernelServer(this Kernel kernel, TextReader inputStream, TextWriter outputStream, DirectoryInfo workingDir)
        {
            if (kernel == null)
            {
                throw new ArgumentNullException(nameof(kernel));
            }

            var input        = new TextReaderInputStream(inputStream);
            var output       = new TextWriterOutputStream(outputStream);
            var kernelServer = new KernelServer(kernel, input, output, workingDir);

            kernel.RegisterForDisposal(kernelServer);
            return(kernelServer);
        }
        public static KernelClient CreateKernelClient(this Process remote)
        {
            if (remote == null)
            {
                throw new ArgumentNullException(nameof(remote));
            }

            if (!remote.StartInfo.RedirectStandardInput || !remote.StartInfo.RedirectStandardOutput)
            {
                throw new InvalidOperationException("StandardInput and StandardOutput must be redirected");
            }

            var input        = new TextReaderInputStream(remote.StandardOutput);
            var output       = new TextWriterOutputStream(remote.StandardInput);
            var kernelClient = new KernelClient(input, output);

            return(kernelClient);
        }