Class RawPDU
Encapsulates PDU data for reading or writing
Inheritance
Implements
Inherited Members
Namespace: FellowOakDicom.Network
Assembly: fo-dicom.core.dll
Syntax
public class RawPDU : IDisposable, IAsyncDisposable
Constructors
RawPDU(RawPduType, IMemoryProvider, Encoding)
Initializes new PDU for writing
Declaration
public RawPDU(RawPduType type, IMemoryProvider memoryProvider, Encoding encoding = null)
Parameters
Type | Name | Description |
---|---|---|
RawPduType | type | Type of PDU |
IMemoryProvider | memoryProvider | The memory provider that will be used to allocate buffers |
System.Text.Encoding | encoding | The encoding to use for encoding text |
RawPDU(RawPduType, IMemoryProvider, Encoding, Stream, Boolean)
Initializes new PDU for writing to a stream
Declaration
public RawPDU(RawPduType type, IMemoryProvider memoryProvider, Encoding encoding, Stream stream, bool leaveOpen)
Parameters
Type | Name | Description |
---|---|---|
RawPduType | type | Type of PDU |
IMemoryProvider | memoryProvider | The memory provider that will be used to allocate buffers |
System.Text.Encoding | encoding | The encoding to use for encoding text |
System.IO.Stream | stream | The stream to write to |
System.Boolean | leaveOpen | Whether the stream should be disposed or not when this RawPDU is disposed |
RawPDU(Byte[], IMemoryProvider, Encoding)
Initializes new PDU reader from buffer
Declaration
public RawPDU(byte[] buffer, IMemoryProvider memoryProvider, Encoding encoding = null)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | Buffer |
IMemoryProvider | memoryProvider | The memory provider that will be used to allocate buffers |
System.Text.Encoding | encoding | The encoding to use for decoding text |
RawPDU(MemoryStream, IMemoryProvider, Encoding)
Initializes new PDU reader from a stream
Declaration
public RawPDU(MemoryStream stream, IMemoryProvider memoryProvider, Encoding encoding = null)
Parameters
Type | Name | Description |
---|---|---|
System.IO.MemoryStream | stream | Stream |
IMemoryProvider | memoryProvider | The memory provider that will be used to allocate buffers |
System.Text.Encoding | encoding | The encoding to use for decoding text |
Remarks
The created object takes ownership of the stream
Properties
Length
PDU length
Declaration
public uint Length { get; }
Property Value
Type | Description |
---|---|
System.UInt32 |
Type
PDU type
Declaration
public RawPduType Type { get; }
Property Value
Type | Description |
---|---|
RawPduType |
Methods
Dispose()
Declaration
public void Dispose()
DisposeAsync()
Declaration
public ValueTask DisposeAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask |
MarkLength16(String)
Marks position to write 16-bit length value
Declaration
public void MarkLength16(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Field name |
ReadByte(String)
Read byte from PDU
Declaration
public byte ReadByte(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of field |
Returns
Type | Description |
---|---|
System.Byte | Field value |
ReadBytes(String, Byte[], Int32, Int32)
Read bytes from PDU
Declaration
public void ReadBytes(string name, byte[] buffer, int index, int count)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of field |
System.Byte[] | buffer | The buffer to read data into |
System.Int32 | index | The starting point in the buffer |
System.Int32 | count | Number of bytes to read |
ReadBytes(String, Int32)
Read bytes from PDU
Declaration
public byte[] ReadBytes(string name, int count)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of field |
System.Int32 | count | Number of bytes to read |
Returns
Type | Description |
---|---|
System.Byte[] | Field value |
ReadString(String, Int32)
Reads string from PDU
Declaration
public string ReadString(string name, int numberOfBytes)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of field |
System.Int32 | numberOfBytes | Number of bytes to read |
Returns
Type | Description |
---|---|
System.String | Field value |
ReadUInt16(String)
Read ushort from PDU
Declaration
public ushort ReadUInt16(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of field |
Returns
Type | Description |
---|---|
System.UInt16 | Field value |
ReadUInt32(String)
Reads uint from PDU
Declaration
public uint ReadUInt32(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of field |
Returns
Type | Description |
---|---|
System.UInt32 | Field value |
Reset()
Reset PDU read stream
Declaration
public void Reset()
Save(IFileReference)
Saves PDU to file
Declaration
public void Save(IFileReference file)
Parameters
Type | Name | Description |
---|---|---|
IFileReference | file | file |
SkipBytes(String, Int32)
Skips ahead in PDU
Declaration
public void SkipBytes(string name, int count)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of field |
System.Int32 | count | Number of bytes to skip |
ToString()
Gets string describing this PDU
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | PDU description |
Overrides
Write(String, Byte)
Writes byte to PDU
Declaration
public void Write(string name, byte value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Field name |
System.Byte | value | Field value |
Write(String, Byte, Int32)
Writes byte to PDU multiple times
Declaration
public void Write(string name, byte value, int count)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Field name |
System.Byte | value | Field value |
System.Int32 | count | Number of times to write PDU value |
Write(String, Byte[])
Writes byte[] to PDU
Declaration
public void Write(string name, byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Field name |
System.Byte[] | value | Field value |
Write(String, Byte[], Int32, Int32)
Writes byte[] to PDU
Declaration
public void Write(string name, byte[] value, int index, int count)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Field name |
System.Byte[] | value | Field value |
System.Int32 | index | The zero based index at which to start reading from the |
System.Int32 | count | How mant bytes from |
Write(String, String)
Writes string to PDU
Declaration
public void Write(string name, string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Field name |
System.String | value | Field value |
Write(String, String, Int32, Char)
Writes string to PDU
Declaration
public void Write(string name, string value, int count, char pad)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Field name |
System.String | value | Field value |
System.Int32 | count | Number of characters to write |
System.Char | pad | Padding character |
Write(String, UInt16)
Writes ushort to PDU
Declaration
public void Write(string name, ushort value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Field name |
System.UInt16 | value | Field value |
Write(String, UInt32)
Writes uint to PDU
Declaration
public void Write(string name, uint value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Field name |
System.UInt32 | value | Field value |
WriteLength16()
Writes 16-bit length to top length marker
Declaration
public void WriteLength16()
WritePDU(Stream)
Writes PDU to stream
Declaration
public void WritePDU(Stream s)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | s | Output stream |
WritePDUAsync(Stream, CancellationToken)
Writes PDU to stream
Declaration
public async Task WritePDUAsync(Stream s, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | s | Output stream |
System.Threading.CancellationToken | cancellationToken | The token that cancels the asynchronous write operation |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |