Edit

Share via


AsnDecoder.TryReadEncodedValue Method

Definition

Attempts locate the contents range for the encoded value at the beginning of the source buffer using the specified encoding rules.

public:
 static bool TryReadEncodedValue(ReadOnlySpan<System::Byte> source, System::Formats::Asn1::AsnEncodingRules ruleSet, [Runtime::InteropServices::Out] System::Formats::Asn1::Asn1Tag % tag, [Runtime::InteropServices::Out] int % contentOffset, [Runtime::InteropServices::Out] int % contentLength, [Runtime::InteropServices::Out] int % bytesConsumed);
public static bool TryReadEncodedValue (ReadOnlySpan<byte> source, System.Formats.Asn1.AsnEncodingRules ruleSet, out System.Formats.Asn1.Asn1Tag tag, out int contentOffset, out int contentLength, out int bytesConsumed);
static member TryReadEncodedValue : ReadOnlySpan<byte> * System.Formats.Asn1.AsnEncodingRules * Asn1Tag * int * int * int -> bool
Public Shared Function TryReadEncodedValue (source As ReadOnlySpan(Of Byte), ruleSet As AsnEncodingRules, ByRef tag As Asn1Tag, ByRef contentOffset As Integer, ByRef contentLength As Integer, ByRef bytesConsumed As Integer) As Boolean

Parameters

source
ReadOnlySpan<Byte>

The buffer containing encoded data.

ruleSet
AsnEncodingRules

The encoding constraints to use when interpreting the data.

tag
Asn1Tag

When this method returns, the tag identifying the content. This parameter is treated as uninitialized.

contentOffset
Int32

When this method returns, the offset of the content payload relative to the start of source. This parameter is treated as uninitialized.

contentLength
Int32

When this method returns, the number of bytes in the content payload (which may be 0). This parameter is treated as uninitialized.

bytesConsumed
Int32

When this method returns, the total number of bytes for the encoded value. This parameter is treated as uninitialized.

Returns

true if source represents a valid structural encoding for the specified encoding rules; otherwise, false.

Exceptions

ruleSet is not defined.

Remarks

This method performs very little validation on the contents. If the encoded value uses a definite length, the contents are not inspected at all. If the encoded value uses an indefinite length, the contents are only inspected as necessary to determine the location of the relevant end-of-contents marker.

When the encoded value uses an indefinite length, the bytesConsumed value will be larger than the sum of contentOffset and contentLength to account for the end-of-contents marker.

Applies to