Exemple #1
0
        /// <summary>
        /// Reads a generic value from a byte array.
        /// </summary>
        /// <typeparam name="T">Type of the value, that should be read from the binary stream.</typeparam>
        /// <param name="data">Binary data stream, within the value should be read.</param>
        /// <param name="index">Byte position of the values within the array.</param>
        /// <returns>Deserialized value</returns>
        public virtual T GetValue <T>(byte[] data, int index)
        {
            ConversionHandler <T> converter = _genericHandlers[typeof(T)] as ConversionHandler <T>;

            if (converter != null)
            {
                return(converter.GetMethod(data, index));
            }
            else
            {
                throw new ArgumentException();
            }
        }