예제 #1
0
        /// <summary>
        ///   Reads the next value as an Enumerated with tag UNIVERSAL 10, converting it to the
        ///   non-[<see cref="FlagsAttribute"/>] enum specfied by <paramref name="tEnum"/>.
        /// </summary>
        /// <param name="expectedTag">The tag to check for before reading.</param>
        /// <param name="tEnum">Type object representing the destination type.</param>
        /// <returns>
        ///   the Enumerated value converted to a <paramref name="tEnum"/>.
        /// </returns>
        /// <remarks>
        ///   This method does not validate that the return value is defined within
        ///   <paramref name="tEnum"/>.
        /// </remarks>
        /// <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 --OR--
        ///   the encoded value is too big to fit in a <paramref name="tEnum"/> value
        /// </exception>
        /// <exception cref="ArgumentException">
        ///   <paramref name="tEnum"/> is not an enum type --OR--
        ///   <paramref name="tEnum"/> was declared with <see cref="FlagsAttribute"/>
        ///   --OR--
        ///   <paramref name="tEnum"/>.<see cref="Asn1Tag.TagClass"/> is
        ///   <see cref="TagClass.Universal"/>, but
        ///   <paramref name="tEnum"/>.<see cref="Asn1Tag.TagValue"/> is not correct for
        ///   the method
        /// </exception>
        public Enum ReadEnumeratedValue(Asn1Tag expectedTag, Type tEnum)
        {
            AsnValueReader valueReader = OpenValueReader();
            Enum           ret         = valueReader.ReadEnumeratedValue(expectedTag, tEnum);

            valueReader.MatchSlice(ref _data);
            return(ret);
        }