SwapBytes() public static method

public static SwapBytes ( byte byteArray, int size, int dataSize ) : void
byteArray byte
size int
dataSize int
return void
示例#1
0
        private void BlockRead(BinaryReader reader, Array array, int dataSize)
        {
            int i = Buffer.ByteLength(array);

            if (this.arrayBuffer == null || (i > this.arrayBuffer.Length && this.arrayBuffer.Length != this.ArrayBufferLength))
            {
                this.arrayBuffer = new byte[(i > this.ArrayBufferLength) ? this.ArrayBufferLength : i];
            }
            int num = 0;

            while (i > 0)
            {
                int num2 = (i >= this.arrayBuffer.Length) ? this.arrayBuffer.Length : i;
                int num3 = 0;
                do
                {
                    int num4 = reader.Read(this.arrayBuffer, num3, num2 - num3);
                    if (num4 == 0)
                    {
                        break;
                    }
                    num3 += num4;
                }while (num3 < num2);
IL_A6:
                if (!BitConverter.IsLittleEndian && dataSize > 1)
                {
                    BinaryCommon.SwapBytes(this.arrayBuffer, num2, dataSize);
                }
                Buffer.BlockCopy(this.arrayBuffer, 0, array, num, num2);
                i   -= num2;
                num += num2;
                continue;
                goto IL_A6;
            }
        }
示例#2
0
        private void BlockRead(BinaryReader reader, Array array, int dataSize)
        {
            int totalSize = Buffer.ByteLength(array);

            if (arrayBuffer == null || (totalSize > arrayBuffer.Length && arrayBuffer.Length != ArrayBufferLength))
            {
                arrayBuffer = new byte [totalSize <= ArrayBufferLength ? totalSize : ArrayBufferLength];
            }

            int pos = 0;

            while (totalSize > 0)
            {
                int size = totalSize < arrayBuffer.Length ? totalSize : arrayBuffer.Length;
                int ap   = 0;
                do
                {
                    int nr = reader.Read(arrayBuffer, ap, size - ap);
                    if (nr == 0)
                    {
                        break;
                    }
                    ap += nr;
                } while (ap < size);

                if (!BitConverter.IsLittleEndian && dataSize > 1)
                {
                    BinaryCommon.SwapBytes(arrayBuffer, size, dataSize);
                }

                Buffer.BlockCopy(arrayBuffer, 0, array, pos, size);
                totalSize -= size;
                pos       += size;
            }
        }
示例#3
0
        private void BlockWrite(BinaryWriter writer, Array array, int dataSize)
        {
            int totalSize = Buffer.ByteLength(array);

            if (arrayBuffer == null || (totalSize > arrayBuffer.Length && arrayBuffer.Length != ArrayBufferLength))
            {
                arrayBuffer = new byte [totalSize <= ArrayBufferLength ? totalSize : ArrayBufferLength];
            }

            int pos = 0;

            while (totalSize > 0)
            {
                int size = totalSize < arrayBuffer.Length ? totalSize : arrayBuffer.Length;
                Buffer.BlockCopy(array, pos, arrayBuffer, 0, size);

                if (!BitConverter.IsLittleEndian && dataSize > 1)
                {
                    BinaryCommon.SwapBytes(arrayBuffer, size, dataSize);
                }

                writer.Write(arrayBuffer, 0, size);
                totalSize -= size;
                pos       += size;
            }
        }
示例#4
0
        private void BlockWrite(BinaryWriter writer, Array array, int dataSize)
        {
            int i = Buffer.ByteLength(array);

            if (this.arrayBuffer == null || (i > this.arrayBuffer.Length && this.arrayBuffer.Length != this.ArrayBufferLength))
            {
                this.arrayBuffer = new byte[(i > this.ArrayBufferLength) ? this.ArrayBufferLength : i];
            }
            int num = 0;

            while (i > 0)
            {
                int num2 = (i >= this.arrayBuffer.Length) ? this.arrayBuffer.Length : i;
                Buffer.BlockCopy(array, num, this.arrayBuffer, 0, num2);
                if (!BitConverter.IsLittleEndian && dataSize > 1)
                {
                    BinaryCommon.SwapBytes(this.arrayBuffer, num2, dataSize);
                }
                writer.Write(this.arrayBuffer, 0, num2);
                i   -= num2;
                num += num2;
            }
        }