Class FileByteSource
- Namespace
- FellowOakDicom.IO
- Assembly
- fo-dicom.core.dll
File byte source for reading.
public class FileByteSource : IByteSource, IDisposable
- Inheritance
-
FileByteSource
- Implements
- Inherited Members
- Extension Methods
Constructors
FileByteSource(IFileReference, FileReadOption, int)
Initializes an instance of FileByteSource.
public FileByteSource(IFileReference file, FileReadOption readOption, int largeObjectSize)
Parameters
file
IFileReferenceFile to read from.
readOption
FileReadOptionOption how to deal with large values, if they should be loaded directly into memory or lazy loaded on demand
largeObjectSize
intCustom limit of what are large values and what are not. If 0 is passend, then the default of 64k is used.
Properties
Endian
Gets or sets the endianness.
public Endian Endian { get; set; }
Property Value
IsEOF
Gets whether end-of-source is reached.
public bool IsEOF { get; }
Property Value
LargeObjectSize
Gets or sets the size of what is considered a large object.
public int LargeObjectSize { get; set; }
Property Value
Position
Gets the current read position.
public long Position { get; }
Property Value
Methods
Dispose()
public void Dispose()
Dispose(bool)
Perform disposal.
protected virtual void Dispose(bool disposing)
Parameters
disposing
booltrue if disposal request originates from Dispose call, false if request originates from sestructor.
GetBuffer(uint)
Gets a byte buffer of specified length from the current position and moves to subsequent position.
public IByteBuffer GetBuffer(uint count)
Parameters
count
uintNumber of bytes to read.
Returns
- IByteBuffer
Byte buffer containing the read bytes.
GetBufferAsync(uint)
Asynchronously gets a byte buffer of specified length from the current position and moves to subsequent position.
public Task<IByteBuffer> GetBufferAsync(uint count)
Parameters
count
uintNumber of bytes to read.
Returns
- Task<IByteBuffer>
Awaitable byte buffer containing the read bytes.
GetBytes(byte[], int, int)
Gets a specified number of bytes from the current position and moves to subsequent position.
The bytes will be written to buffer
public int GetBytes(byte[] buffer, int index, int count)
Parameters
buffer
byte[]The buffer to write the bytes to
index
intThe index in the buffer at which to start writing
count
intNumber of bytes to read.
Returns
- int
The number of bytes that were filled in the buffer
GetBytes(int)
Gets a specified number of bytes from the current position and moves to subsequent position.
public byte[] GetBytes(int count)
Parameters
count
intNumber of bytes to read.
Returns
- byte[]
Array of bytes.
GetDouble()
Gets a double precision floating point value (64 bits) from the current position and moves to subsequent position.
public double GetDouble()
Returns
- double
Double precision floating point value.
GetInt16()
Gets a signed short (16 bits) from the current position and moves to subsequent position.
public short GetInt16()
Returns
- short
Signed short.
GetInt32()
Gets a signed integer (32 bits) from the current position and moves to subsequent position.
public int GetInt32()
Returns
- int
Signed integer.
GetInt64()
Gets a signed long (64 bits) from the current position and moves to subsequent position.
public long GetInt64()
Returns
- long
Signed long.
GetSingle()
Gets a single precision floating point value (32 bits) from the current position and moves to subsequent position.
public float GetSingle()
Returns
- float
Single precision floating point value.
GetStream()
Get stream of this byte source.
public Stream GetStream()
Returns
- Stream
The stream.
GetUInt16()
Gets an unsigned short (16 bits) from the current position and moves to subsequent position.
public ushort GetUInt16()
Returns
- ushort
Unsigned short.
GetUInt32()
Gets an unsigned integer (32 bits) from the current position and moves to subsequent position.
public uint GetUInt32()
Returns
- uint
Unsigned integer.
GetUInt64()
Gets an unsigned long (64 bits) from the current position and moves to subsequent position.
public ulong GetUInt64()
Returns
- ulong
Unsigned long.
GetUInt8()
Gets one byte from the current position and moves to subsequent position.
public byte GetUInt8()
Returns
- byte
Single byte.
GoTo(long)
Sets the current read position to the position position
public void GoTo(long position)
Parameters
position
longthe position to seek to
Require(uint)
Verifies that there is a sufficient number of bytes to read.
public bool Require(uint count)
Parameters
count
uintRequired number of bytes.
Returns
- bool
true if source contains sufficient number of remaining bytes, false otherwise.
Require(uint, ByteSourceCallback, object)
Verifies that there is a sufficient number of bytes to read.
public bool Require(uint count, ByteSourceCallback callback, object state)
Parameters
count
uintRequired number of bytes.
callback
ByteSourceCallbackByte source callback.
state
objectCallback state.
Returns
- bool
true if source contains sufficient number of remaining bytes, false otherwise.
Skip(uint)
Skip position count
number of bytes.
public void Skip(uint count)
Parameters
count
uintNumber of bytes to skip.