Table of Contents

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 RawPduType

Type of PDU

memoryProvider IMemoryProvider

The memory provider that will be used to allocate buffers

encoding Encoding

The 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 RawPduType

Type of PDU

memoryProvider IMemoryProvider

The memory provider that will be used to allocate buffers

encoding Encoding

The encoding to use for encoding text

stream Stream

The stream to write to

leaveOpen bool

Whether 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 IMemoryProvider

The memory provider that will be used to allocate buffers

encoding Encoding

The 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 MemoryStream

Stream

memoryProvider IMemoryProvider

The memory provider that will be used to allocate buffers

encoding Encoding

The 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

uint

Type

PDU type

public RawPduType Type { get; }

Property Value

RawPduType

Methods

Dispose()

public void Dispose()

DisposeAsync()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

public ValueTask DisposeAsync()

Returns

ValueTask

MarkLength16(string)

Marks position to write 16-bit length value

public void MarkLength16(string name)

Parameters

name string

Field name

ReadByte(string)

Read byte from PDU

public byte ReadByte(string name)

Parameters

name string

Name 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 string

Name of field

buffer byte[]

The buffer to read data into

index int

The starting point in the buffer

count int

Number of bytes to read

ReadBytes(string, int)

Read bytes from PDU

public byte[] ReadBytes(string name, int count)

Parameters

name string

Name of field

count int

Number of bytes to read

Returns

byte[]

Field value

ReadString(string, int)

Reads string from PDU

public string ReadString(string name, int numberOfBytes)

Parameters

name string

Name of field

numberOfBytes int

Number of bytes to read

Returns

string

Field value

ReadUInt16(string)

Read ushort from PDU

public ushort ReadUInt16(string name)

Parameters

name string

Name of field

Returns

ushort

Field value

ReadUInt32(string)

Reads uint from PDU

public uint ReadUInt32(string name)

Parameters

name string

Name 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 IFileReference

file

SkipBytes(string, int)

Skips ahead in PDU

public void SkipBytes(string name, int count)

Parameters

name string

Name of field

count int

Number of bytes to skip

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

name string

Field name

value byte

Field value

Write(string, byte, int)

Writes byte to PDU multiple times

public void Write(string name, byte value, int count)

Parameters

name string

Field name

value byte

Field value

count int

Number of times to write PDU value

Write(string, byte[])

Writes byte[] to PDU

public void Write(string name, byte[] value)

Parameters

name string

Field name

value byte[]

Field value

Write(string, byte[], int, int)

Writes byte[] to PDU

public void Write(string name, byte[] value, int index, int count)

Parameters

name string

Field name

value byte[]

Field value

index int

The zero based index at which to start reading from the value

count int

How mant bytes from value to write

Write(string, string)

Writes string to PDU

public void Write(string name, string value)

Parameters

name string

Field name

value string

Field value

Write(string, string, int, char)

Writes string to PDU

public void Write(string name, string value, int count, char pad)

Parameters

name string

Field name

value string

Field value

count int

Number of characters to write

pad char

Padding character

Write(string, ushort)

Writes ushort to PDU

public void Write(string name, ushort value)

Parameters

name string

Field name

value ushort

Field value

Write(string, uint)

Writes uint to PDU

public void Write(string name, uint value)

Parameters

name string

Field name

value uint

Field value

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 Stream

Output stream

WritePDUAsync(Stream, CancellationToken)

Writes PDU to stream

public Task WritePDUAsync(Stream s, CancellationToken cancellationToken)

Parameters

s Stream

Output stream

cancellationToken CancellationToken

The token that cancels the asynchronous write operation

Returns

Task