Esempio n. 1
0
        /// <summary>
        /// Creates a <see cref="BinaryValueReader"/> for reading a string.
        /// </summary>
        /// <param name="data">The string to read.</param>
        /// <param name="useEnumNames">If true, Enums I/O will be done using the Enum's name. If false,
        /// Enum I/O will use the underlying integer value of the Enum.</param>
        /// <exception cref="ArgumentNullException"><paramref name="data"/> is null.</exception>
        public static BinaryValueReader CreateFromString(string data, bool useEnumNames = true)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }

            var bytes  = BitStream.StringToByteArray(data);
            var reader = new BitStream(bytes);

            return(new BinaryValueReader(reader, useEnumNames));
        }