protected override void ReadData(ESPReader reader) { Type tType = typeof(T); Type readType = tType; if (tType.IsEnum) { readType = Enum.GetUnderlyingType(tType); } string typeName = readType.FullName; switch (typeName) { case "System.Byte": //Debug.Assert(size == 1); Value = (T)(object)reader.ReadByte(); break; case "System.SByte": Debug.Assert(size == 1); Value = (T)(object)reader.ReadSByte(); break; case "System.Char": Debug.Assert(size == 1); Value = (T)(object)reader.ReadChar(); break; case "System.UInt16": Debug.Assert(size == 2); Value = (T)(object)reader.ReadUInt16(); break; case "System.Int16": Debug.Assert(size == 2); Value = (T)(object)reader.ReadInt16(); break; case "System.UInt32": Debug.Assert(size == 4); Value = (T)(object)reader.ReadUInt32(); break; case "System.Int32": Debug.Assert(size == 4); Value = (T)(object)reader.ReadInt32(); break; case "System.Single": Debug.Assert(size == 4); Value = (T)(object)reader.ReadSingle(); break; case "System.UInt64": Debug.Assert(size == 8); Value = (T)(object)reader.ReadUInt64(); break; case "System.Int64": Debug.Assert(size == 8); Value = (T)(object)reader.ReadInt64(); break; case "System.Byte[]": Value = (T)(object)reader.ReadBytes(size); break; case "System.Char[]": string tempstring = new string(reader.ReadChars(size)); tempstring = tempstring.Replace("\0", ""); Value = (T)(object)tempstring.ToCharArray(); break; case "System.String": string outString = new String(reader.ReadChars(size - 1)); reader.ReadByte(); Value = (T)(object)(outString.Replace("\0", "")); break; case "ESPSharp.DataTypes.Color": var color = new DataTypes.Color(); color.ReadBinary(reader); Value = (T)(object)color; break; case "ESPSharp.DataTypes.XYFloat": var temp = new DataTypes.XYFloat(); temp.ReadBinary(reader); Value = (T)(object)temp; break; default: throw new NotImplementedException(typeName + " is not yet implemented."); } }