public T ReadValue <T> () { if (typeof(T).Equals(typeof(byte))) { return((T)System.Convert.ChangeType(ReceivedDate.ReadByte(), typeof(T))); } else if (typeof(T).Equals(typeof(int))) { return((T)System.Convert.ChangeType(ReceivedDate.ReadInt(), typeof(T))); } else if (typeof(T).Equals(typeof(float))) { return((T)System.Convert.ChangeType(ReceivedDate.ReadFloat(), typeof(T))); } else if (typeof(T).Equals(typeof(long))) { return((T)System.Convert.ChangeType(ReceivedDate.ReadLong(), typeof(T))); } else if (typeof(T).Equals(typeof(bool))) { return((T)System.Convert.ChangeType(ReceivedDate.ReadBool(), typeof(T))); } else if (typeof(T).Equals(typeof(short))) { return((T)System.Convert.ChangeType(ReceivedDate.ReadShort(), typeof(T))); } else if (typeof(T).Equals(typeof(string))) { int length = ReadValue <int>(); return((T)System.Convert.ChangeType(ReceivedDate.ReadString(length), typeof(T))); } else if (typeof(T).Equals(typeof(MNT_NetworkPackage))) { byte[] bytes = ReadArray <byte>(); MNT_NetworkPackage pack = new MNT_NetworkPackage(bytes); return((T)System.Convert.ChangeType(pack, typeof(T))); } else if (typeof(T).Equals(typeof(Vector3))) { Vector3 vect = new Vector3(); vect.x = ReadValue <float>(); vect.y = ReadValue <float>(); vect.z = ReadValue <float>(); return((T)System.Convert.ChangeType(vect, typeof(T))); } else { return(default(T)); } }
//-------------------------------------- // PUBLIC METHODS //-------------------------------------- public T ReadValue <T> () { if (typeof(T).Equals(typeof(byte))) { return((T)System.Convert.ChangeType(ReceivedDate.ReadByte(), typeof(T))); } else if (typeof(T).Equals(typeof(int))) { return((T)System.Convert.ChangeType(ReceivedDate.ReadInt(), typeof(T))); } else if (typeof(T).Equals(typeof(float))) { return((T)System.Convert.ChangeType(ReceivedDate.ReadFloat(), typeof(T))); } else if (typeof(T).Equals(typeof(long))) { return((T)System.Convert.ChangeType(ReceivedDate.ReadLong(), typeof(T))); } else if (typeof(T).Equals(typeof(bool))) { return((T)System.Convert.ChangeType(ReceivedDate.ReadBool(), typeof(T))); } else if (typeof(T).Equals(typeof(short))) { return((T)System.Convert.ChangeType(ReceivedDate.ReadShort(), typeof(T))); } else if (typeof(T).Equals(typeof(string))) { int length = ReadValue <int>(); return((T)System.Convert.ChangeType(ReceivedDate.ReadString(length), typeof(T))); } else { return(default(T)); } }