internal ReadOnlySpan <byte> ReadIntegerBytes(Asn1Tag?expectedTag = default) { ReadOnlySpan <byte> ret = AsnDecoder.ReadIntegerBytes(_span, _ruleSet, out int consumed, expectedTag); _span = _span.Slice(consumed); return(ret); }
/// <summary> /// Reads the next value as a Integer 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, or <see langword="null"/> for the default tag (Universal 2). /// </param> /// <returns> /// The bytes of the Integer value, in signed big-endian form. /// </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> public ReadOnlyMemory <byte> ReadIntegerBytes(Asn1Tag?expectedTag = null) { ReadOnlySpan <byte> bytes = AsnDecoder.ReadIntegerBytes(_data.Span, RuleSet, out int consumed, expectedTag); ReadOnlyMemory <byte> ret = AsnDecoder.Slice(_data, bytes); _data = _data.Slice(consumed); return(ret); }