Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ReadArray< T >()

int System.IO.UnmanagedMemoryAccessor.ReadArray< T > ( long position,
T[] array,
int offset,
int count )
inlineinherited
Type Constraints
T :struct 

Definition at line 301 of file UnmanagedMemoryAccessor.cs.

301 : struct
302 {
303 if (array == null)
304 {
305 throw new ArgumentNullException("array", SR.ArgumentNull_Buffer);
306 }
307 if (offset < 0)
308 {
309 throw new ArgumentOutOfRangeException("offset", SR.ArgumentOutOfRange_NeedNonNegNum);
310 }
311 if (count < 0)
312 {
313 throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NeedNonNegNum);
314 }
315 if (array.Length - offset < count)
316 {
317 throw new ArgumentException(SR.Argument_InvalidOffLen);
318 }
319 if (!_isOpen)
320 {
321 throw new ObjectDisposedException("UnmanagedMemoryAccessor", SR.ObjectDisposed_ViewAccessorClosed);
322 }
323 if (!_canRead)
324 {
325 throw new NotSupportedException(SR.NotSupported_Reading);
326 }
327 if (position < 0)
328 {
329 throw new ArgumentOutOfRangeException("position", SR.ArgumentOutOfRange_NeedNonNegNum);
330 }
331 uint num = SafeBuffer.AlignedSizeOf<T>();
332 if (position >= _capacity)
333 {
334 throw new ArgumentOutOfRangeException("position", SR.ArgumentOutOfRange_PositionLessThanCapacityRequired);
335 }
336 int num2 = count;
337 long num3 = _capacity - position;
338 if (num3 < 0)
339 {
340 num2 = 0;
341 }
342 else
343 {
344 ulong num4 = (ulong)(num * count);
345 if ((ulong)num3 < num4)
346 {
347 num2 = (int)(num3 / num);
348 }
349 }
350 _buffer.ReadArray((ulong)(_offset + position), array, offset, num2);
351 return num2;
352 }

References System.IO.UnmanagedMemoryAccessor._buffer, System.IO.UnmanagedMemoryAccessor._canRead, System.IO.UnmanagedMemoryAccessor._capacity, System.IO.UnmanagedMemoryAccessor._isOpen, System.IO.UnmanagedMemoryAccessor._offset, System.SR.Argument_InvalidOffLen, System.SR.ArgumentNull_Buffer, System.SR.ArgumentOutOfRange_NeedNonNegNum, System.SR.ArgumentOutOfRange_PositionLessThanCapacityRequired, System.array, System.count, System.SR.NotSupported_Reading, System.SR.ObjectDisposed_ViewAccessorClosed, and System.offset.