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

定义

如果值包含在单个(基元)编码中,则尝试在指定编码规则下,从带有指定标记的 source 中获取位字符串值。Attempts to get a Bit String value from source with a specified tag under the specified encoding rules, if the value is contained in a single (primitive) encoding.

public static bool TryReadPrimitiveBitString (ReadOnlySpan<byte> source, System.Formats.Asn1.AsnEncodingRules ruleSet, out int unusedBitCount, out ReadOnlySpan<byte> value, out int bytesConsumed, System.Formats.Asn1.Asn1Tag? expectedTag = default);
static member TryReadPrimitiveBitString : ReadOnlySpan<byte> * System.Formats.Asn1.AsnEncodingRules * int * ReadOnlySpan * int * Nullable<System.Formats.Asn1.Asn1Tag> -> bool
Public Shared Function TryReadPrimitiveBitString (source As ReadOnlySpan(Of Byte), ruleSet As AsnEncodingRules, ByRef unusedBitCount As Integer, ByRef value As ReadOnlySpan(Of Byte), ByRef bytesConsumed As Integer, Optional expectedTag As Nullable(Of Asn1Tag) = Nothing) As Boolean

参数

source
ReadOnlySpan<Byte>

包含编码数据的缓冲区。The buffer containing encoded data.

ruleSet
AsnEncodingRules

解释数据时要使用的编码约束。The encoding constraints to use when interpreting the data.

unusedBitCount
Int32

成功时,将接收由编写器报告为“未使用”的最后一个字节中的位数。On success, receives the number of bits in the last byte which were reported as "unused" by the writer. 该参数未经初始化即被处理。This parameter is treated as uninitialized.

value
ReadOnlySpan<Byte>

成功时,将接收与位字符串的值相对应的输入缓冲区的切片。On success, receives a slice of the input buffer that corresponds to the value of the Bit String. 该参数未经初始化即被处理。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.

expectedTag
Nullable<Asn1Tag>

读取前要检查的标记,或使用 null 作为默认标记(通用 3)。The tag to check for before reading, or null for the default tag (Universal 3).

返回

Boolean

如果位字符串值具有基元编码,并且所有报告为“未使用”的位均设置为 0,则为 true;否则为 falsetrue if the Bit String value has a primitive encoding and all of the bits reported as unused are set to 0; otherwise, false.

例外

未定义 ruleSetruleSet is not defined.

下一个值没有正确的标记。the next value does not have the correct tag. -或- 在当前编码规则下,长度编码无效。-or- the length encoding is not valid under the current encoding rules. -或- 在当前编码规则下,内容无效。-or- the contents are not valid under the current encoding rules.

expectedTag.TagClassexpectedTag.TagClass Universal,但 expectedTag.TagValueis Universal, but expectedTag.TagValue 对于此方法而言是不正确的。is not correct for the method.

适用于