Share via


AsnDecoder.TryReadEncodedValue 方法

定義

嘗試使用指定的編碼規則,尋找 source 緩衝區開頭處編碼值的內容範圍。

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>

包含編碼資料的緩衝區。

ruleSet
AsnEncodingRules

要在解譯資料時使用的編碼條件約束。

tag
Asn1Tag

當此方法傳回時,識別內容的標籤。 這個參數會被視為未初始化。

contentOffset
Int32

當此方法傳回時,相對於 source 開頭的內容承載位移。 這個參數會被視為未初始化。

contentLength
Int32

當此方法傳回時,內容承載中的位元組數 (可能是 0)。 這個參數會被視為未初始化。

bytesConsumed
Int32

當此方法傳回時,編碼值的位元組總數。 這個參數會被視為未初始化。

傳回

如果 source 表示所指定編碼規則的有效結構編碼,則為 true,否則為 false

例外狀況

未定義 ruleSet

備註

此方法會對內容執行非常少的驗證。 如果編碼的值使用明確長度,則完全不會檢查內容。 如果編碼的值使用無限長度,則只會視需要檢查內容,以判斷相關內容結尾標記的位置。

當編碼值使用無限長度時, bytesConsumed 值會大於 和的總 contentOffsetcontentLength ,以考慮內容結束標記。

適用於