/// <summary> /// Reads the next value as a Enumerated with a specified tag, returning the contents /// as a <see cref="ReadOnlyMemory{T}"/> over the original data. /// </summary> /// <param name="expectedTag">The tag to check for before reading.</param> /// <returns> /// The bytes of the Enumerated value, in signed big-endian form. /// </returns> /// <exception cref="CryptographicException"> /// 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 /// </exception> /// <exception cref="ArgumentException"> /// <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> /// <seealso cref="ReadEnumeratedValue{TEnum}(Asn1Tag)"/> public ReadOnlyMemory <byte> ReadEnumeratedBytes(Asn1Tag expectedTag) { AsnValueReader valueReader = OpenValueReader(); ReadOnlySpan <byte> bytes = valueReader.ReadEnumeratedBytes(expectedTag); ReadOnlyMemory <byte> memory = AsnValueReader.Slice(_data, bytes); valueReader.MatchSlice(ref _data); return(memory); }