AsnDecoder.ReadNamedBitListValue Método

Definição

Sobrecargas

ReadNamedBitListValue(ReadOnlySpan<Byte>, AsnEncodingRules, Type, Int32, Nullable<Asn1Tag>)

Lê um NamedBitList de source com uma marca especificada de acordo com as regras de codificação determinadas, convertendo-o para a enumeração [FlagsAttribute] especificada por flagsEnumType.Reads a NamedBitList from source with a specified tag under the specified encoding rules, converting it to the [FlagsAttribute] enum specified by flagsEnumType.

ReadNamedBitListValue<TFlagsEnum>(ReadOnlySpan<Byte>, AsnEncodingRules, Int32, Nullable<Asn1Tag>)

Lê um NamedBitList de source com uma marca especificada de acordo com as regras de codificação determinadas, convertendo-o para a enumeração [FlagsAttribute] especificada por TFlagsEnum.Reads a NamedBitList from source with a specified tag under the specified encoding rules, converting it to the [FlagsAttribute] enum specified by TFlagsEnum.

ReadNamedBitListValue(ReadOnlySpan<Byte>, AsnEncodingRules, Type, Int32, Nullable<Asn1Tag>)

Lê um NamedBitList de source com uma marca especificada de acordo com as regras de codificação determinadas, convertendo-o para a enumeração [FlagsAttribute] especificada por flagsEnumType.Reads a NamedBitList from source with a specified tag under the specified encoding rules, converting it to the [FlagsAttribute] enum specified by flagsEnumType.

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

Parâmetros

source
ReadOnlySpan<Byte>

Buffer que contém dados codificados.The buffer containing encoded data.

ruleSet
AsnEncodingRules

As restrições de codificação a serem usadas ao interpretar os dados.The encoding constraints to use when interpreting the data.

flagsEnumType
Type

Objeto de tipo que representa o tipo de destino.Type object representing the destination type.

bytesConsumed
Int32

Quando esse método é retornado, o número total de bytes para o valor codificado.When this method returns, the total number of bytes for the encoded value. Esse parâmetro é tratado como não inicializado.This parameter is treated as uninitialized.

expectedTag
Nullable<Asn1Tag>

A marca a verificar antes da leitura ou null para a marca padrão (Universal 3).The tag to check for before reading, or null for the default tag (Universal 3).

Retornos

Enum

O valor de NamedBitList convertido em flagsEnumType.The NamedBitList value converted to a flagsEnumType.

Exceções

ruleSet não está definido.ruleSet is not defined.

o valor a seguir não tem a marca correta.the next value does not have the correct tag. -ou- a codificação de comprimento não é válida de acordo com as regras de codificação atuais.-or- the length encoding is not valid under the current encoding rules. -ou- o conteúdo não é válido de acordo com as regras de codificação atuais.-or- the contents are not valid under the current encoding rules. -ou- o valor codificado é muito grande para caber em um valor flagsEnumType.-or- - the encoded value is too big to fit in a flagsEnumType value.

flagsEnumType não é um tipo enumerado.flagsEnumType is not an enum type. -ou- flagsEnumType não foi declarado com FlagsAttribute -ou- expectedTag.TagClass-or- flagsEnumType was not declared with FlagsAttribute -or- expectedTag.TagClass é Universal, mas expectedTag.TagValueis Universal, but expectedTag.TagValue não está correto para o método.is not correct for the method.

flagsEnumType é nullflagsEnumType is null

Aplica-se a

ReadNamedBitListValue<TFlagsEnum>(ReadOnlySpan<Byte>, AsnEncodingRules, Int32, Nullable<Asn1Tag>)

Lê um NamedBitList de source com uma marca especificada de acordo com as regras de codificação determinadas, convertendo-o para a enumeração [FlagsAttribute] especificada por TFlagsEnum.Reads a NamedBitList from source with a specified tag under the specified encoding rules, converting it to the [FlagsAttribute] enum specified by TFlagsEnum.

public static TFlagsEnum ReadNamedBitListValue<TFlagsEnum> (ReadOnlySpan<byte> source, System.Formats.Asn1.AsnEncodingRules ruleSet, out int bytesConsumed, System.Formats.Asn1.Asn1Tag? expectedTag = default) where TFlagsEnum : Enum;
static member ReadNamedBitListValue : ReadOnlySpan<byte> * System.Formats.Asn1.AsnEncodingRules * int * Nullable<System.Formats.Asn1.Asn1Tag> -> 'FlagsEnum (requires 'FlagsEnum :> Enum)
Public Shared Function ReadNamedBitListValue(Of TFlagsEnum As Enum) (source As ReadOnlySpan(Of Byte), ruleSet As AsnEncodingRules, ByRef bytesConsumed As Integer, Optional expectedTag As Nullable(Of Asn1Tag) = Nothing) As TFlagsEnum

Parâmetros de tipo

TFlagsEnum

Tipo de enumeração de destinoDestination enum type

Parâmetros

source
ReadOnlySpan<Byte>

Buffer que contém dados codificados.The buffer containing encoded data.

ruleSet
AsnEncodingRules

As restrições de codificação a serem usadas ao interpretar os dados.The encoding constraints to use when interpreting the data.

bytesConsumed
Int32

Quando esse método é retornado, o número total de bytes para o valor codificado.When this method returns, the total number of bytes for the encoded value. Esse parâmetro é tratado como não inicializado.This parameter is treated as uninitialized.

expectedTag
Nullable<Asn1Tag>

A marca a verificar antes da leitura ou null para a marca padrão (Universal 3).The tag to check for before reading, or null for the default tag (Universal 3).

Retornos

TFlagsEnum

O valor de NamedBitList convertido em TFlagsEnum.The NamedBitList value converted to a TFlagsEnum.

Exceções

ruleSet não está definido.ruleSet is not defined.

o valor a seguir não tem a marca correta.the next value does not have the correct tag. -ou- a codificação de comprimento não é válida de acordo com as regras de codificação atuais.-or- the length encoding is not valid under the current encoding rules. -ou- o conteúdo não é válido de acordo com as regras de codificação atuais.-or- the contents are not valid under the current encoding rules. -ou- o valor codificado é muito grande para caber em um valor TFlagsEnum.-or- the encoded value is too big to fit in a TFlagsEnum value.

TFlagsEnum não é um tipo enumerado.TFlagsEnum is not an enum type. -ou- TFlagsEnum não foi declarado com FlagsAttribute -ou- expectedTag.TagClass-or- TFlagsEnum was not declared with FlagsAttribute -or- expectedTag.TagClass é Universal, mas expectedTag.TagValueis Universal, but expectedTag.TagValue não está correto para o método.is not correct for the method.

Comentários

O alinhamento de bit executado por esse método é interpretar o bit mais significativo no primeiro byte do valor como o bit menos significativo em <typeparamref Name = "TFlagsEnum>, com bits aumentando em valor até o bit menos significativo do primeiro byte, prosseguindo com o bit mais significativo do segundo byte e assim por diante.The bit alignment performed by this method is to interpret the most significant bit in the first byte of the value as the least significant bit in <typeparamref name="TFlagsEnum>, with bits increasing in value until the least significant bit of the first byte, proceeding with the most significant bit of the second byte, and so on. Nesse esquema, a declaração de tipo ASN. 1 e a enumeração C# a seguir podem ser usadas juntas: KeyUsage ::= BIT STRING { digitalSignature (0), nonRepudiation (1), keyEncipherment (2), dataEncipherment (3), keyAgreement (4), keyCertSign (5), cRLSign (6), encipherOnly (7), decipherOnly (8) } [Flags] enum KeyUsage { None = 0, DigitalSignature = 1 << (0), NonRepudiation = 1 << (1), KeyEncipherment = 1 << (2), DataEncipherment = 1 << (3), KeyAgreement = 1 << (4), KeyCertSign = 1 << (5), CrlSign = 1 << (6), EncipherOnly = 1 << (7), DecipherOnly = 1 << (8), } Under this scheme, the following ASN.1 type declaration and C# enumeration can be used together: KeyUsage ::= BIT STRING { digitalSignature (0), nonRepudiation (1), keyEncipherment (2), dataEncipherment (3), keyAgreement (4), keyCertSign (5), cRLSign (6), encipherOnly (7), decipherOnly (8) } [Flags] enum KeyUsage { None = 0, DigitalSignature = 1 << (0), NonRepudiation = 1 << (1), KeyEncipherment = 1 << (2), DataEncipherment = 1 << (3), KeyAgreement = 1 << (4), KeyCertSign = 1 << (5), CrlSign = 1 << (6), EncipherOnly = 1 << (7), DecipherOnly = 1 << (8), } Observe que, embora o exemplo aqui Use o NamedBitList de uso do RFC 3280 (4.2.1.3), o exemplo de enum usa valores que são diferentes de System. Security. Cryptography. X509Certificates. X509KeyUsageFlags.Note that while the example here uses the KeyUsage NamedBitList from RFC 3280 (4.2.1.3), the example enum uses values thar are different from System.Security.Cryptography.X509Certificates.X509KeyUsageFlags.

Aplica-se a