Struct Reader
Provides methods for reading a D-Bus message.
public ref struct Reader
- Inherited Members
Methods
AlignStruct()
Aligns the reader to a struct boundary.
public void AlignStruct()
HasNext(ArrayEnd)
Checks if there are more elements to read in the array.
public bool HasNext(ArrayEnd iterator)
Parameters
iteratorArrayEndThe ArrayEnd iterator returned by ReadArrayStart(DBusType).
Returns
ReadArrayOfBool()
Reads an array of booleans.
public bool[] ReadArrayOfBool()
Returns
- bool[]
ReadArrayOfByte()
Reads an array of bytes.
public byte[] ReadArrayOfByte()
Returns
- byte[]
ReadArrayOfDouble()
Reads an array of double values.
public double[] ReadArrayOfDouble()
Returns
- double[]
ReadArrayOfHandle<T>()
Reads an array of Unix file descriptor handles.
public T[] ReadArrayOfHandle<T>() where T : SafeHandle, new()
Returns
- T[]
Type Parameters
TThe SafeHandle type to read.
ReadArrayOfInt16()
Reads an array of signed 16-bit integers.
public short[] ReadArrayOfInt16()
Returns
- short[]
ReadArrayOfInt32()
Reads an array of signed 32-bit integers.
public int[] ReadArrayOfInt32()
Returns
- int[]
ReadArrayOfInt64()
Reads an array of signed 64-bit integers.
public long[] ReadArrayOfInt64()
Returns
- long[]
ReadArrayOfObjectPath()
Reads an array of object paths.
public ObjectPath[] ReadArrayOfObjectPath()
Returns
ReadArrayOfSignature()
Reads an array of signatures.
public Signature[] ReadArrayOfSignature()
Returns
ReadArrayOfString()
Reads an array of strings.
public string[] ReadArrayOfString()
Returns
- string[]
ReadArrayOfUInt16()
Reads an array of unsigned 16-bit integers.
public ushort[] ReadArrayOfUInt16()
Returns
- ushort[]
ReadArrayOfUInt32()
Reads an array of unsigned 32-bit integers.
public uint[] ReadArrayOfUInt32()
Returns
- uint[]
ReadArrayOfUInt64()
Reads an array of unsigned 64-bit integers.
public ulong[] ReadArrayOfUInt64()
Returns
- ulong[]
ReadArrayOfVariantValue()
Reads an array of variant values.
public VariantValue[] ReadArrayOfVariantValue()
Returns
ReadArrayStart(DBusType)
Reads the start of an array and returns a position for detecting the end.
public ArrayEnd ReadArrayStart(DBusType elementType)
Parameters
elementTypeDBusTypeThe type of array elements.
Returns
ReadBool()
Reads a boolean value.
public bool ReadBool()
Returns
ReadByte()
Reads a byte value.
public byte ReadByte()
Returns
ReadDictionaryOfStringToVariantValue()
Reads a dictionary with string keys and VariantValue values.
public Dictionary<string, VariantValue> ReadDictionaryOfStringToVariantValue()
Returns
Remarks
This is a helper method for reading the common 'a{sv}' D-Bus type.
ReadDictionaryStart()
Reads the start of a dictionary and returns a position for detecting the end.
public ArrayEnd ReadDictionaryStart()
Returns
ReadDouble()
Reads a double.
public double ReadDouble()
Returns
ReadHandleRaw()
Reads a Unix file descriptor handle as a raw IntPtr.
public IntPtr ReadHandleRaw()
Returns
Remarks
A handle can only be read once.
To skip reading a handle, call ReadHandle<SkipSafeHandle>(), which will return a disposed SkipSafeHandle instance without consuming the underlying handle.
The handle is still owned (i.e. Disposed) by the Message.
Exceptions
- DBusReadException
The file descriptor is not present in the message.
- DBusUnexpectedValueException
The handle was already read.
ReadHandle<T>()
Reads a Unix file descriptor handle.
public T ReadHandle<T>() where T : SafeHandle, new()
Returns
- T
Type Parameters
TThe SafeHandle type to read. If
Tis SkipSafeHandle, the method returns a disposed SkipSafeHandle instance without consuming the underlying handle.
Remarks
A handle can only be read once. Use SkipSafeHandle to avoid consuming the handle.
Exceptions
- DBusReadException
The file descriptor is not present in the message.
- DBusUnexpectedValueException
The handle was already read.
ReadInt16()
Reads a signed 16-bit integer.
public short ReadInt16()
Returns
ReadInt32()
Reads a signed 32-bit integer.
public int ReadInt32()
Returns
ReadInt64()
Reads a signed 64-bit integer.
public long ReadInt64()
Returns
ReadObjectPath()
Reads an object path.
public ObjectPath ReadObjectPath()
Returns
ReadObjectPathAsSpan()
Reads an object path as a byte span.
public ReadOnlySpan<byte> ReadObjectPathAsSpan()
Returns
ReadObjectPathAsString()
Reads an object path as a string.
public string ReadObjectPathAsString()
Returns
ReadSignature()
Reads a signature.
public Signature ReadSignature()
Returns
ReadSignature(ReadOnlySpan<byte>)
Reads and validates a signature matches the expected value.
public void ReadSignature(ReadOnlySpan<byte> expected)
Parameters
expectedReadOnlySpan<byte>The expected signature.
ReadSignature(string)
Reads and validates a signature matches the expected value.
public void ReadSignature(string expected)
Parameters
expectedstringThe expected signature string.
ReadSignatureAsSpan()
Reads a signature as a byte span.
public ReadOnlySpan<byte> ReadSignatureAsSpan()
Returns
ReadSignatureAsString()
Reads a signature as a string.
public string ReadSignatureAsString()
Returns
ReadString()
Reads a string.
public string ReadString()
Returns
ReadStringAsSpan()
Reads a string as a byte span.
public ReadOnlySpan<byte> ReadStringAsSpan()
Returns
ReadUInt16()
Reads an unsigned 16-bit integer.
public ushort ReadUInt16()
Returns
ReadUInt32()
Reads an unsigned 32-bit integer.
public uint ReadUInt32()
Returns
ReadUInt64()
Reads an unsigned 64-bit integer.
public ulong ReadUInt64()
Returns
ReadVariantValue()
Reads a variant value.
public VariantValue ReadVariantValue()
Returns
- VariantValue
The variant value.
SkipTo(ArrayEnd)
Skips to the end of the array.
public void SkipTo(ArrayEnd end)
Parameters
endArrayEndThe ArrayEnd iterator returned by ReadArrayStart(DBusType).