Читати англійською

Поділитися через


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<byte> source, System.Formats.Asn1.AsnEncodingRules ruleSet, out System.Formats.Asn1.Asn1Tag tag, out int contentOffset, out int contentLength, out int bytesConsumed);

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

Продукт Версії
.NET 5, 6 (package-provided), 6, 7 (package-provided), 7, 8 (package-provided), 8, 9 (package-provided), 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)