public IPacketBuilder WriteOperation(RequestOperation operation)
        {
            var bytes = m_buffer.Array;

            m_offset    = m_position;
            m_position += Offset.EndOfHeader;

            Array.Clear(bytes, m_offset + 2, Offset.EndOfHeader - 2);
            bytes[m_offset + Offset.StartOfHeader] = 0x80;

            byte opcode = 0x00;

            switch (operation)
            {
            case RequestOperation.Get:
                break;

            case RequestOperation.Set:
                opcode = 0x01;
                break;

            case RequestOperation.Delete:
                opcode = 0x04;
                break;

            case RequestOperation.Increment:
                opcode = 0x05;
                break;

            case RequestOperation.Decrement:
                opcode = 0x06;
                break;

            case RequestOperation.Version:
                opcode = 0x0B;
                break;

            case RequestOperation.Flush:
                opcode = 0x08;
                break;

            default:
                throw new NotImplementedException(operation.ToString());
            }

            bytes[m_offset + Offset.OperationCode] = opcode;
            return(this);
        }
Beispiel #2
0
        public IPacketBuilder WriteOperation(RequestOperation operation)
        {
            Debug.Assert(m_position == 0, "position != 0");
            switch (operation)
            {
            case RequestOperation.Get:
                WriteBytes(g_get, 0, g_get.Length);
                break;

            case RequestOperation.Set:
                WriteBytes(g_set, 0, g_set.Length);
                break;

            case RequestOperation.Delete:
                WriteBytes(g_delete, 0, g_delete.Length);
                break;

            case RequestOperation.Increment:
                WriteBytes(g_incr, 0, g_incr.Length);
                break;

            case RequestOperation.Decrement:
                WriteBytes(g_decr, 0, g_decr.Length);
                break;

            case RequestOperation.Gets:
                WriteBytes(g_gets, 0, g_gets.Length);
                break;

            case RequestOperation.CheckAndSet:
                WriteBytes(g_cas, 0, g_cas.Length);
                break;

            case RequestOperation.Version:
                WriteBytes(g_version, 0, g_version.Length);
                break;

            case RequestOperation.Flush:
                WriteBytes(g_flush_all, 0, g_flush_all.Length);
                break;

            default:
                throw new NotImplementedException(operation.ToString());
            }

            return(this);
        }