AsnDecoder.TryReadEncodedValue(ReadOnlySpan<Byte>, AsnEncodingRules, Asn1Tag, Int32, Int32, Int32) 方法

定义

尝试使用指定编码规则查找 source 缓冲区开头编码值的内容范围。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

参数

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

此方法返回时,为内容有效负载相对于 source 起始位置的偏移量。When this method returns, the offset of the content payload relative to the start of source. 该参数未经初始化即被处理。This parameter is treated as uninitialized.

contentLength
Int32

此方法返回时,为内容有效负载中的字节数(可能为 0)。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.

返回

Boolean

如果 source 表示指定编码规则的有效结构编码,则为 true;否则为 falsetrue if source represents a valid structural encoding for the specified encoding rules; otherwise, false.

例外

未定义 ruleSetruleSet is not defined.

注解

此方法对内容执行非常少的验证。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.

当编码值使用无限长度时, bytesConsumed 值将大于和的总和, contentOffset contentLength 以考虑内容的结束标记。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.

适用于