Esempio n. 1
0
        public NumbersReaderVisitor(BitsReader reader)
        {
            if (reader == null)
            {
                throw new System.ArgumentNullException("reader");
            }

            mBitsReader = reader;
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a new <see cref="ObjectReader"/> instance for reading the supplied data
        /// </summary>
        /// <typeparam name="T">The type of objects for reading</typeparam>
        /// <param name="bytes">The array of bytes from which to read objects</param>
        /// <returns>An object that is used to read objects from byte array</returns>
        /// <exception cref="ArgumentException"></exception>
        /// <exception cref="ArgumentNullException"></exception>
        /// <remarks>Target type <typeparamref name="T"/> should be a POCO class</remarks>
        public static ObjectReader <T> Create <T>(byte[] bytes) where T : class
        {
            var             type = typeof(T);
            List <Property> props;

            if (Cache.TryGetValue(type, out props) == false)
            {
                props = GetTypeProperties(type);
                Cache.Add(type, props);
            }

            var reader = new BitsReader(bytes);

            return(new ObjectReader <T>(props, reader));
        }