Class TlvObjects
Utility methods to encode and decode BER-TLV data.
public static class TlvObjects- Inheritance
- 
      objectTlvObjects
Methods
DecodeDictionary(ReadOnlySpan<byte>)
Decodes a sequence of BER-TLV encoded data into a mapping of Tag-Value pairs. Iteration order is preserved. If the same tag occurs more than once only the latest will be kept.
public static IReadOnlyDictionary<int, ReadOnlyMemory<byte>> DecodeDictionary(ReadOnlySpan<byte> data)Parameters
- dataReadOnlySpan<byte>
- Sequence of TLV encoded data 
Returns
- IReadOnlyDictionary<int, ReadOnlyMemory<byte>>
- Dictionary of Tag-Value pairs 
DecodeList(ReadOnlySpan<byte>)
Decodes a sequence of BER-TLV encoded data into a list of Tlvs.
public static IReadOnlyList<TlvObject> DecodeList(ReadOnlySpan<byte> data)Parameters
- dataReadOnlySpan<byte>
- Sequence of TLV encoded data 
Returns
EncodeDictionary(IReadOnlyDictionary<int, byte[]>)
public static Memory<byte> EncodeDictionary(IReadOnlyDictionary<int, byte[]> map)Parameters
- mapIReadOnlyDictionary<int, byte[]>
Returns
- Memory<byte>
EncodeList(IEnumerable<TlvObject>)
Encodes a list of Tlvs into a sequence of BER-TLV encoded data.
public static byte[] EncodeList(IEnumerable<TlvObject> list)Parameters
- listIEnumerable<TlvObject>
- List of Tlvs to encode 
Returns
- byte[]
- BER-TLV encoded list 
EncodeMany(params TlvObject[])
Encodes an array of Tlvs into a sequence of BER-TLV encoded data.
public static byte[] EncodeMany(params TlvObject[] tlvs)Parameters
- tlvsTlvObject[]
- Array of Tlvs to encode 
Returns
- byte[]
- BER-TLV encoded array 
UnpackValue(int, ReadOnlySpan<byte>)
Decode a single TLV encoded object, returning only the value.
public static Memory<byte> UnpackValue(int expectedTag, ReadOnlySpan<byte> tlvData)Parameters
- expectedTagint
- The expected tag value of the given TLV data 
- tlvDataReadOnlySpan<byte>
- The TLV data 
Returns
- Memory<byte>
- The value of the TLV 
Exceptions
- InvalidOperationException
- If the TLV tag differs from expectedTag