Class RawPDU
- Namespace
- FellowOakDicom.Network
- Assembly
- fo-dicom.core.dll
Encapsulates PDU data for reading or writing
public class RawPDU : IDisposable, IAsyncDisposable
- Inheritance
-
RawPDU
- Implements
- Inherited Members
- Extension Methods
Constructors
RawPDU(RawPduType, IMemoryProvider, Encoding)
Initializes new PDU for writing
public RawPDU(RawPduType type, IMemoryProvider memoryProvider, Encoding encoding = null)
Parameters
type
RawPduTypeType of PDU
memoryProvider
IMemoryProviderThe memory provider that will be used to allocate buffers
encoding
EncodingThe encoding to use for encoding text
RawPDU(RawPduType, IMemoryProvider, Encoding, Stream, bool)
Initializes new PDU for writing to a stream
public RawPDU(RawPduType type, IMemoryProvider memoryProvider, Encoding encoding, Stream stream, bool leaveOpen)
Parameters
type
RawPduTypeType of PDU
memoryProvider
IMemoryProviderThe memory provider that will be used to allocate buffers
encoding
EncodingThe encoding to use for encoding text
stream
StreamThe stream to write to
leaveOpen
boolWhether the stream should be disposed or not when this RawPDU is disposed
RawPDU(byte[], IMemoryProvider, Encoding)
Initializes new PDU reader from buffer
public RawPDU(byte[] buffer, IMemoryProvider memoryProvider, Encoding encoding = null)
Parameters
buffer
byte[]Buffer
memoryProvider
IMemoryProviderThe memory provider that will be used to allocate buffers
encoding
EncodingThe encoding to use for decoding text
RawPDU(MemoryStream, IMemoryProvider, Encoding)
Initializes new PDU reader from a stream
public RawPDU(MemoryStream stream, IMemoryProvider memoryProvider, Encoding encoding = null)
Parameters
stream
MemoryStreamStream
memoryProvider
IMemoryProviderThe memory provider that will be used to allocate buffers
encoding
EncodingThe encoding to use for decoding text
Remarks
The created object takes ownership of the stream
Properties
Length
PDU length
public uint Length { get; }
Property Value
Type
PDU type
public RawPduType Type { get; }
Property Value
Methods
Dispose()
public void Dispose()
DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
public ValueTask DisposeAsync()
Returns
MarkLength16(string)
Marks position to write 16-bit length value
public void MarkLength16(string name)
Parameters
name
stringField name
ReadByte(string)
Read byte from PDU
public byte ReadByte(string name)
Parameters
name
stringName of field
Returns
- byte
Field value
ReadBytes(string, byte[], int, int)
Read bytes from PDU
public void ReadBytes(string name, byte[] buffer, int index, int count)
Parameters
name
stringName of field
buffer
byte[]The buffer to read data into
index
intThe starting point in the buffer
count
intNumber of bytes to read
ReadBytes(string, int)
Read bytes from PDU
public byte[] ReadBytes(string name, int count)
Parameters
Returns
- byte[]
Field value
ReadString(string, int)
Reads string from PDU
public string ReadString(string name, int numberOfBytes)
Parameters
Returns
- string
Field value
ReadUInt16(string)
Read ushort from PDU
public ushort ReadUInt16(string name)
Parameters
name
stringName of field
Returns
- ushort
Field value
ReadUInt32(string)
Reads uint from PDU
public uint ReadUInt32(string name)
Parameters
name
stringName of field
Returns
- uint
Field value
Reset()
Reset PDU read stream
public void Reset()
Save(IFileReference)
Saves PDU to file
public void Save(IFileReference file)
Parameters
file
IFileReferencefile
SkipBytes(string, int)
Skips ahead in PDU
public void SkipBytes(string name, int count)
Parameters
ToString()
Gets string describing this PDU
public override string ToString()
Returns
- string
PDU description
Write(string, byte)
Writes byte to PDU
public void Write(string name, byte value)
Parameters
Write(string, byte, int)
Writes byte to PDU multiple times
public void Write(string name, byte value, int count)
Parameters
Write(string, byte[])
Writes byte[] to PDU
public void Write(string name, byte[] value)
Parameters
Write(string, byte[], int, int)
Writes byte[] to PDU
public void Write(string name, byte[] value, int index, int count)
Parameters
name
stringField name
value
byte[]Field value
index
intThe zero based index at which to start reading from the
value
count
intHow mant bytes from
value
to write
Write(string, string)
Writes string to PDU
public void Write(string name, string value)
Parameters
Write(string, string, int, char)
Writes string to PDU
public void Write(string name, string value, int count, char pad)
Parameters
name
stringField name
value
stringField value
count
intNumber of characters to write
pad
charPadding character
Write(string, ushort)
Writes ushort to PDU
public void Write(string name, ushort value)
Parameters
Write(string, uint)
Writes uint to PDU
public void Write(string name, uint value)
Parameters
WriteLength16()
Writes 16-bit length to top length marker
public void WriteLength16()
WritePDU(Stream)
Writes PDU to stream
public void WritePDU(Stream s)
Parameters
s
StreamOutput stream
WritePDUAsync(Stream, CancellationToken)
Writes PDU to stream
public Task WritePDUAsync(Stream s, CancellationToken cancellationToken)
Parameters
s
StreamOutput stream
cancellationToken
CancellationTokenThe token that cancels the asynchronous write operation