internal byte[] ReadBitString(out int unusedBitCount, Asn1Tag?expectedTag = default) { byte[] ret = AsnDecoder.ReadBitString( _span, _ruleSet, out unusedBitCount, out int consumed, expectedTag); _span = _span.Slice(consumed); return(ret); }
/// <summary> /// Reads the next value as a BIT STRING with a specified tag, returning the value /// in a byte array. /// </summary> /// <param name="unusedBitCount"> /// On success, receives the number of bits in the last byte which were reported as /// "unused" by the writer. /// </param> /// <param name="expectedTag"> /// The tag to check for before reading, or <see langword="null"/> for the default tag (Universal 1). /// </param> /// <returns> /// A copy of the value in a newly allocated, precisely sized, array. /// </returns> /// <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. /// </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="TryReadPrimitiveBitString"/> /// <seealso cref="TryReadBitString"/> public byte[] ReadBitString(out int unusedBitCount, Asn1Tag?expectedTag = null) { byte[] ret = AsnDecoder.ReadBitString( _data.Span, RuleSet, out unusedBitCount, out int consumed, expectedTag); _data = _data.Slice(consumed); return(ret); }