/// <summary>
        ///  Serializes an operation request.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <param name="operationRequest"> The operation request.</param>
        /// <exception cref="T:System.IO.InvalidDataException">
        /// A value can not be serialized.
        ///</exception>
        ///<exception cref="T:System.ArrayTypeMismatchException">
        ///  A collection with different types can not be serialized.
        ///</exception>
        private static void SerializeOperationRequest(Stream stream, OperationRequest operationRequest)
        {
            IBinaryWriter writer = new BigEndianBinaryWriter(stream);

            writer.WriteByte(operationRequest.OperationCode);
            writer.WriteBoolean(false);
            if (operationRequest.Parameters != null)
            {
                writer.WriteInt16((short)operationRequest.Parameters.Count);
                foreach (KeyValuePair <byte, object> pair in operationRequest.Parameters)
                {
                    writer.WriteByte(pair.Key);
                    GpBinaryByteWriter.Write(writer, pair.Value);
                }
            }
            else
            {
                writer.WriteInt16(0);
            }
        }