コード例 #1
0
        public ArrayImpl SplitBinaryData(BinaryDataContext data, long size)
        {
            if (size <= 0 || size > Int32.MaxValue)
            {
                throw RuntimeException.InvalidNthArgumentValue(2);
            }

            ArrayImpl array    = new ArrayImpl();
            long      dataSize = data.Size();

            if (dataSize < size)
            {
                array.Add(data);
                return(array);
            }

            int readedBytes = 0;
            var dataStream  = data.GetStream();

            while (readedBytes < dataSize)
            {
                int bytesToRead = (int)size;
                if (bytesToRead > dataSize - readedBytes)
                {
                    bytesToRead = (int)(dataSize - readedBytes);
                }

                byte[] buffer = new byte[bytesToRead];
                dataStream.Read(buffer, 0, bytesToRead);
                readedBytes += bytesToRead;
                array.Add(new BinaryDataContext(buffer));
            }

            return(array);
        }
コード例 #2
0
 public FixedArrayImpl(ArrayImpl source)
 {
     _array = new ArrayImpl();
     foreach (var Value in source)
     {
         _array.Add(Value);
     }
 }
コード例 #3
0
        public ArrayImpl SplitBinaryData(BinaryDataContext data, int size)
        {
            // Сделано на int т.к. BinaryContext.Size имеет тип int;
            ArrayImpl array = new ArrayImpl();

            int readedBytes = 0;

            while (readedBytes < data.Buffer.Length)
            {
                int bytesToRead = size;
                if (bytesToRead > data.Buffer.Length - readedBytes)
                {
                    bytesToRead = data.Buffer.Length - readedBytes;
                }

                byte[] buffer = new byte[bytesToRead];
                Buffer.BlockCopy(data.Buffer, readedBytes, buffer, 0, bytesToRead);
                readedBytes += bytesToRead;
                array.Add(new BinaryDataContext(buffer));
            }

            return(array);
        }