A utility class that exposes named pipes operations.
This class uses the exposed exposed kernel32.dll methods by the NamedPipeNative class to provided controlled named pipe functionality.
        /// <summary>
        /// Attempts to establish a connection to the a server named pipe.
        /// </summary>
        /// <remarks>
        /// If the attempt is successful the method creates the
        /// field.<br/><br/>
        /// This method is used when it is not known whether a server pipe already exists.
        /// </remarks>
        /// <returns>True if a connection is established.</returns>
        public bool TryConnect()
        {
            CheckIfDisposed();
            var ReturnVal = NamedPipeWrapper.TryConnectToPipe(_name, Server, out _handle);

            return(ReturnVal);
        }
 /// <summary>
 /// Writes an array of bytes to the pipe connection.
 /// </summary>
 /// <param name="bytes">The bytes array.</param>
 public void WriteBytes(byte[] bytes)
 {
     CheckIfDisposed();
     NamedPipeWrapper.WriteBytes(_handle, bytes);
 }
 /// <summary>
 /// Writes a string to the pipe connection/
 /// </summary>
 /// <param name="text">The text to write.</param>
 public void Write(string text)
 {
     CheckIfDisposed();
     NamedPipeWrapper.Write(_handle, text);
 }
 /// <summary>
 /// Reads a message from the pipe connection.
 /// </summary>
 /// <returns>The bytes read from the pipe connection.</returns>
 public byte[] ReadBytes()
 {
     CheckIfDisposed();
     return(NamedPipeWrapper.ReadBytes(_handle, _maxReadBytes));
 }
 /// <summary>
 /// Reads a message from the pipe connection and converts it to a string
 /// using the UTF8 encoding.
 /// </summary>
 /// <returns>The UTF8 encoded string representation of the data.</returns>
 public string Read()
 {
     CheckIfDisposed();
     return(NamedPipeWrapper.Read(_handle, _maxReadBytes));
 }
 /// <summary>
 /// Connects a client pipe to an existing server one.
 /// </summary>
 public override void Connect()
 {
     CheckIfDisposed();
     _handle = NamedPipeWrapper.ConnectToPipe(_name, Server);
 }