/// <summary> /// Gets the values of the <see cref="DicomElementBinaryData{T}"/> as an array. /// </summary> /// <returns>An array containing the values of this instance.</returns> public T[] ToArray() { if (_array != null) { return(_array); } else { _stream.Position = 0; var valueCount = _stream.Length / _sizeOfT; var values = new T[valueCount]; var buffer = new byte[_bufferSize]; var bytesPosition = 0; int bytesInBuffer; while ((bytesInBuffer = _stream.Read(buffer, 0, _bufferSize)) > 0) { Buffer.BlockCopy(buffer, 0, values, bytesPosition, bytesInBuffer); bytesPosition += bytesInBuffer; } return(values); } }