public static KernelClient CreateKernelClient(this NamedPipeClientStream remote)
        {
            if (remote == null)
            {
                throw new ArgumentNullException(nameof(remote));
            }

            var input        = new PipeStreamInputStream(remote);
            var output       = new PipeStreamOutputStream(remote);
            var kernelClient = new KernelClient(input, output);

            return(kernelClient);
        }
        public static KernelServer CreateKernelServer(this Kernel kernel, NamedPipeServerStream local, DirectoryInfo workingDir)
        {
            if (kernel == null)
            {
                throw new ArgumentNullException(nameof(kernel));
            }
            var input        = new PipeStreamInputStream(local);
            var output       = new PipeStreamOutputStream(local);
            var kernelServer = new KernelServer(kernel, input, output, workingDir);

            kernel.RegisterForDisposal(kernelServer);
            return(kernelServer);
        }
        public static T UseNamedPipeKernelServer <T>(this T kernel, string pipeName, DirectoryInfo workingDir) where T : Kernel
        {
            if (kernel == null)
            {
                throw new ArgumentNullException(nameof(kernel));
            }

            if (string.IsNullOrWhiteSpace(pipeName))
            {
                throw new ArgumentException("Value cannot be null or whitespace.", nameof(pipeName));
            }

            var serverStream = new NamedPipeServerStream(pipeName, PipeDirection.InOut, 1, PipeTransmissionMode.Message, PipeOptions.Asynchronous);

            Task.Run(() =>
            {
                serverStream.WaitForConnection();
                var input        = new PipeStreamInputStream(serverStream);
                var output       = new PipeStreamOutputStream(serverStream);
                var kernelServer = new KernelServer(kernel, input, output, workingDir);
                kernel.RegisterForDisposal(kernelServer);
            });
            return(kernel);
        }