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); }
public FixedArrayImpl(ArrayImpl source) { _array = new ArrayImpl(); foreach (var Value in source) { _array.Add(Value); } }
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); }