Κοινή χρήση μέσω


AsnReader.ReadNamedBitListValue Method

Definition

Overloads

ReadNamedBitListValue(Type, Nullable<Asn1Tag>)

Reads the next value as a NamedBitList with a specified tag, converting it to the [FlagsAttribute] enum specified by flagsEnumType.

ReadNamedBitListValue<TFlagsEnum>(Nullable<Asn1Tag>)

Reads the next value as a NamedBitList with a specified tag, converting it to the [FlagsAttribute] enum specified by TFlagsEnum.

ReadNamedBitListValue(Type, Nullable<Asn1Tag>)

Source:
AsnDecoder.NamedBitList.cs
Source:
AsnDecoder.NamedBitList.cs
Source:
AsnDecoder.NamedBitList.cs
Source:
AsnDecoder.NamedBitList.cs
Source:
AsnDecoder.NamedBitList.cs

Reads the next value as a NamedBitList with a specified tag, converting it to the [FlagsAttribute] enum specified by flagsEnumType.

public Enum ReadNamedBitListValue (Type flagsEnumType, System.Formats.Asn1.Asn1Tag? expectedTag = default);
member this.ReadNamedBitListValue : Type * Nullable<System.Formats.Asn1.Asn1Tag> -> Enum
Public Function ReadNamedBitListValue (flagsEnumType As Type, Optional expectedTag As Nullable(Of Asn1Tag) = Nothing) As Enum

Parameters

flagsEnumType
Type

Type object representing the destination type.

expectedTag
Nullable<Asn1Tag>

The tag to check for before reading.

Returns

The NamedBitList value converted to a flagsEnumType.

Exceptions

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.

-or-

The encoded value is too big to fit in a flagsEnumType value.

flagsEnumType is not an enum type.

-or-

flagsEnumType was not declared with FlagsAttribute

-or-

expectedTag.TagClass is Universal, but expectedTag.TagValue is not correct for the method.

flagsEnumType is null

Applies to

ReadNamedBitListValue<TFlagsEnum>(Nullable<Asn1Tag>)

Source:
AsnDecoder.NamedBitList.cs
Source:
AsnDecoder.NamedBitList.cs
Source:
AsnDecoder.NamedBitList.cs
Source:
AsnDecoder.NamedBitList.cs
Source:
AsnDecoder.NamedBitList.cs

Reads the next value as a NamedBitList with a specified tag, converting it to the [FlagsAttribute] enum specified by TFlagsEnum.

public TFlagsEnum ReadNamedBitListValue<TFlagsEnum> (System.Formats.Asn1.Asn1Tag? expectedTag = default) where TFlagsEnum : Enum;
member this.ReadNamedBitListValue : Nullable<System.Formats.Asn1.Asn1Tag> -> 'FlagsEnum (requires 'FlagsEnum :> Enum)
Public Function ReadNamedBitListValue(Of TFlagsEnum As Enum) (Optional expectedTag As Nullable(Of Asn1Tag) = Nothing) As TFlagsEnum

Type Parameters

TFlagsEnum

Destination enum type.

Parameters

expectedTag
Nullable<Asn1Tag>

The tag to check for before reading.

Returns

TFlagsEnum

The NamedBitList value converted to a TFlagsEnum.

Exceptions

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.

-or-

The encoded value is too big to fit in a TFlagsEnum value.

TFlagsEnum is not an enum type.

-or-

TFlagsEnum was not declared with FlagsAttribute

-or-

expectedTag.TagClass is Universal, but expectedTag.TagValue is not correct for the method.

Remarks

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 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. 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),
}

While the example here uses the KeyUsage NamedBitList from RFC 3280 (4.2.1.3), the example enum uses values that are different from X509KeyUsageFlags.

Applies to