예제 #1
0
        public static byte[] GetBytes(int val, BufferDirection direction = BufferDirection.Forward, BufferEndianess endianess = BufferEndianess.LittleEndian)
        {
            var ret = new byte[4];

            switch (direction)
            {
            case BufferDirection.Forward:
                ret[3] = (byte)(val & 0xFF);
                ret[2] = (byte)((val >> 8) & 0xFF);
                ret[1] = (byte)((val >> 16) & 0xFF);
                ret[0] = (byte)((val >> 24) & 0xFF);
                break;

            case BufferDirection.Backward:
                ret[0] = (byte)(val & 0xFF);
                ret[1] = (byte)((val >> 8) & 0xFF);
                ret[2] = (byte)((val >> 16) & 0xFF);
                ret[3] = (byte)((val >> 24) & 0xFF);
                break;

            default:
                throw new NotSupportedException();
            }
            return(ret);
        }
예제 #2
0
        /// <summary>Returns the requested rows from the Output Buffer.</summary>
        /// <param name="bufferDirection">The direction to move in the buffer.</param>
        /// <param name="maxRows">The maximum rows to return.</param>
        /// <returns>Rows from the output buffer.</returns>
        public string[] GetRows(BufferDirection bufferDirection, int maxRows)
        {
            lock (this.lockObject)
            {
                int start = this.CurrentLocation;
                int end   = 0;

                switch (bufferDirection)
                {
                case BufferDirection.Repeat:
                    start = start - maxRows;
                    if (start < 0)
                    {
                        start = 0;
                    }

                    end = start + maxRows;
                    break;

                case BufferDirection.Backward:
                    start = start - (2 * maxRows);
                    if (start < 0)
                    {
                        start = 0;
                    }

                    end = start + maxRows;
                    break;

                case BufferDirection.Forward:
                    end = start + maxRows;
                    break;

                case BufferDirection.ForwardAllData:
                    end = this.outputBuffer.Count;
                    break;
                }

                if (end > this.outputBuffer.Count)
                {
                    end = this.outputBuffer.Count;
                }

                string[] output = new string[end - start];

                for (int i = start; i < end; i++)
                {
                    output[i - start] = this.outputBuffer[i];
                }

                this.CurrentLocation = end;
                return(output);
            }
        }
예제 #3
0
        public static byte GetLSB(ushort val, BufferDirection direction = BufferDirection.Forward, BufferEndianess endianess = BufferEndianess.LittleEndian)
        {
            switch (direction)
            {
            case BufferDirection.Forward:
                return((byte)(val & 0xFF));

            case BufferDirection.Backward:
                return((byte)((val >> 8) & 0xFF));

            default:
                throw new NotSupportedException();
            }
        }
예제 #4
0
        public static short GetShort(byte msb, byte lsb, BufferDirection direction = BufferDirection.Forward, BufferEndianess endianess = BufferEndianess.LittleEndian)
        {
            switch (direction)
            {
            case BufferDirection.Forward:
                return((short)((msb << 8) | lsb));

            case BufferDirection.Backward:
                return((short)((lsb << 8) | msb));

            default:
                throw new NotSupportedException();
            }
        }
예제 #5
0
        public static int GetInt(byte msb4, byte msb3, byte lsb2, byte lsb1, BufferDirection direction = BufferDirection.Forward, BufferEndianess endianess = BufferEndianess.LittleEndian)
        {
            switch (direction)
            {
            case BufferDirection.Forward:
                return((((((msb4 << 8) | msb3) << 8) | lsb2) << 8) | lsb1);

            case BufferDirection.Backward:
                return((((((lsb1 << 8) | lsb2) << 8) | msb3) << 8) | msb4);

            default:
                throw new NotSupportedException();
            }
        }
예제 #6
0
        /// <summary>Sends data from the output buffer to the client.</summary>
        /// <param name="bufferDirection">Direction to move in the buffer.</param>
        public void ProcessBuffer(BufferDirection bufferDirection)
        {
            if (OutputBuffer.HasMoreData)
            {
                string[] output = OutputBuffer.GetRows(bufferDirection, PagingRowLimit);

                bool   appendOverflow = OutputBuffer.HasMoreData;
                string data           = (AtNewLine ? null : AnsiSequences.NewLine) + BufferHandler.Format(
                    output,
                    appendOverflow,
                    OutputBuffer.CurrentLocation,
                    OutputBuffer.Length);

                Send(data, true);
            }
        }
예제 #7
0
        /// <summary>Sends data from the output buffer to the client.</summary>
        /// <param name="bufferDirection">Direction to move in the buffer.</param>
        public void ProcessBuffer(BufferDirection bufferDirection)
        {
            if (this.OutputBuffer.HasMoreData)
            {
                string[] output = this.OutputBuffer.GetRows(bufferDirection, this.PagingRowLimit);

                bool   appendOverflow = this.OutputBuffer.HasMoreData;
                string data           = BufferHandler.Format(
                    output,
                    false,
                    appendOverflow,
                    this.OutputBuffer.CurrentLocation,
                    this.OutputBuffer.Length);

                this.Send(data, false, true);
            }
        }
예제 #8
0
        /// <summary>
        /// Sends data from the output buffer to the client.
        /// </summary>
        /// <param name="bufferDirection">Direction to move in the buffer.</param>
        public void ProcessBuffer(BufferDirection bufferDirection)
        {
            if (this.OutputBuffer.HasMoreData)
            {
                string[] output = this.OutputBuffer.GetRows(bufferDirection, this.PagingRowLimit);

                bool appendOverflow = this.OutputBuffer.HasMoreData;
                string data = BufferHandler.Format(
                    output,
                    false,
                    appendOverflow,
                    this.OutputBuffer.CurrentLocation,
                    this.OutputBuffer.Length);

                this.Send(data, false, true);
            }
        }
예제 #9
0
 private void PushBufferToLog(BufferDirection Direction, Byte[] Buffer)
 {
     // Удалил, т.к. больно уж это подробная отладка получается
 }
예제 #10
0
 private void PushBufferToLog(BufferDirection Direction, Byte[] Buffer)
 {
     // Удалил, т.к. больно уж это подробная отладка получается
 }
예제 #11
0
 public void ProcessBuffer(BufferDirection bufferDirection)
 {
     throw new NotImplementedException();
 }
예제 #12
0
 protected void SetBufferDirection(BufferDirection bufferDirection)
 {
     _bufferDirection = bufferDirection;
 }