/// <summary> /// Reads the next value as an Enumerated with a specified tag, converting it to the /// non-[<see cref="FlagsAttribute"/>] enum specified by <typeparamref name="TEnum"/>. /// </summary> /// <param name="expectedTag"> /// The tag to check for before reading, or <see langword="null"/> for the default tag (Universal 10). /// </param> /// <typeparam name="TEnum">Destination enum type</typeparam> /// <returns> /// The Enumerated value converted to a <typeparamref name="TEnum"/>. /// </returns> /// <remarks> /// This method does not validate that the return value is defined within /// <typeparamref name="TEnum"/>. /// </remarks> /// <exception cref="AsnContentException"> /// 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 <typeparamref name="TEnum"/> value. /// </exception> /// <exception cref="ArgumentException"> /// <typeparamref name="TEnum"/> is not an enum type. /// /// -or- /// /// <typeparamref name="TEnum"/> was declared with <see cref="FlagsAttribute"/>. /// /// -or- /// /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagClass"/> is /// <see cref="TagClass.Universal"/>, but /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagValue"/> is not correct for /// the method. /// </exception> public TEnum ReadEnumeratedValue <TEnum>(Asn1Tag?expectedTag = null) where TEnum : Enum { TEnum ret = AsnDecoder.ReadEnumeratedValue <TEnum>(_data.Span, RuleSet, out int consumed, expectedTag); _data = _data.Slice(consumed); return(ret); }
/// <summary> /// Reads the next value as an Enumerated with a specified tag, converting it to the /// non-[<see cref="FlagsAttribute"/>] enum specified by <paramref name="enumType"/>. /// </summary> /// <param name="enumType">Type object representing the destination type.</param> /// <param name="expectedTag"> /// The tag to check for before reading, or <see langword="null"/> for the default tag (Universal 10). /// </param> /// <returns> /// The Enumerated value converted to a <paramref name="enumType"/>. /// </returns> /// <remarks> /// This method does not validate that the return value is defined within /// <paramref name="enumType"/>. /// </remarks> /// <exception cref="AsnContentException"> /// 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 <paramref name="enumType"/> value. /// </exception> /// <exception cref="ArgumentException"> /// <paramref name="enumType"/> is not an enum type. /// /// -or- /// /// <paramref name="enumType"/> was declared with <see cref="FlagsAttribute"/>. /// /// -or- /// /// <paramref name="enumType"/>.<see cref="Asn1Tag.TagClass"/> is /// <see cref="TagClass.Universal"/>, but /// <paramref name="enumType"/>.<see cref="Asn1Tag.TagValue"/> is not correct for /// the method. /// </exception> /// <exception cref="ArgumentNullException"> /// <paramref name="enumType"/> is <see langword="null" />. /// </exception> public Enum ReadEnumeratedValue(Type enumType, Asn1Tag?expectedTag = null) { Enum ret = AsnDecoder.ReadEnumeratedValue(_data.Span, RuleSet, enumType, out int consumed, expectedTag); _data = _data.Slice(consumed); return(ret); }
internal TEnum ReadEnumeratedValue <TEnum>(Asn1Tag?expectedTag = null) where TEnum : Enum { TEnum ret = AsnDecoder.ReadEnumeratedValue <TEnum>(_span, _ruleSet, out int consumed, expectedTag); _span = _span.Slice(consumed); return(ret); }