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
typeRawPduTypeType of PDU
memoryProviderIMemoryProviderThe memory provider that will be used to allocate buffers
encodingEncodingThe 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
typeRawPduTypeType of PDU
memoryProviderIMemoryProviderThe memory provider that will be used to allocate buffers
encodingEncodingThe encoding to use for encoding text
streamStreamThe stream to write to
leaveOpenboolWhether 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
bufferbyte[]Buffer
memoryProviderIMemoryProviderThe memory provider that will be used to allocate buffers
encodingEncodingThe 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
streamMemoryStreamStream
memoryProviderIMemoryProviderThe memory provider that will be used to allocate buffers
encodingEncodingThe 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
namestringField name
ReadByte(string)
Read byte from PDU
public byte ReadByte(string name)
  Parameters
namestringName 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
namestringName of field
bufferbyte[]The buffer to read data into
indexintThe starting point in the buffer
countintNumber 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
namestringName of field
Returns
- ushort
 Field value
ReadUInt32(string)
Reads uint from PDU
public uint ReadUInt32(string name)
  Parameters
namestringName 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
fileIFileReferencefile
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
namestringField name
valuebyte[]Field value
indexintThe zero based index at which to start reading from the
valuecountintHow mant bytes from
valueto 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
namestringField name
valuestringField value
countintNumber of characters to write
padcharPadding 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
sStreamOutput stream
WritePDUAsync(Stream, CancellationToken)
Writes PDU to stream
public Task WritePDUAsync(Stream s, CancellationToken cancellationToken)
  Parameters
sStreamOutput stream
cancellationTokenCancellationTokenThe token that cancels the asynchronous write operation