Exemple #1
0
        /// <summary>
        /// Read a generic value from a memory address.
        /// </summary>
        /// <typeparam name="T">The type to read.</typeparam>
        /// <param name="memaddress"></param>
        /// <returns></returns>
        public T ReadGeneric <T>(long memaddress) where T : struct
        {
            int size = GenericBitConverter.GetTypeSize(typeof(T));

            byte[] bytes = ReadByteArray(memaddress, size);
            return(GenericBitConverter.ToStruct <T>(bytes));
        }
        /// <summary>
        /// Get the value this object points to as the specified type, if possible.
        /// </summary>
        /// <returns></returns>
        public T GetValue()
        {
            // Get the bytes and handle the null case
            byte[] bytes = GetBytes(TargetSize);
            if (bytes == null)
            {
                return(default(T));
            }

            return(GenericBitConverter.ToStruct <T>(bytes));
        }