// Read a single value from JSON public static object ReadJSONValue(Jboy.JsonReader reader, FieldInfo field) { var fieldType = field.FieldType; if (fieldType == typeof(int)) { return((int)(reader.ReadNumber())); } else if (fieldType == typeof(uint)) { return((uint)(reader.ReadNumber())); } else if (fieldType == typeof(long)) { return((long)(reader.ReadNumber())); } else if (fieldType == typeof(byte)) { return((byte)(reader.ReadNumber())); } else if (fieldType == typeof(double)) { return(reader.ReadNumber()); } else if (fieldType == typeof(float)) { return((float)reader.ReadNumber()); } else if (fieldType == typeof(KeyCode)) { return((KeyCode)(reader.ReadNumber())); } else if (fieldType == typeof(string)) { string stringObject; if (reader.TryReadString(out stringObject)) { return(stringObject); } else { reader.ReadNull(); return(null); } } else if (fieldType == typeof(int[])) { return(Jboy.Json.ReadObject <int[]>(reader)); } else if (fieldType == typeof(Color)) { return(ColorSerializer.JsonDeserializer(reader)); } else if (fieldType == typeof(ServerType)) { return(ServerTypeSerializer.JsonDeserializer(reader)); } else if (fieldType == typeof(PlayerQueueStats)) { return(GenericSerializer.ReadJSONClassInstance <PlayerQueueStats>(reader)); } else if (fieldType == typeof(PlayerQueueStats[])) { reader.ReadArrayStart(); PlayerQueueStats[] valArray = new PlayerQueueStats[QueueSettings.queueCount]; for (int i = 0; i < QueueSettings.queueCount; i++) { valArray[i] = GenericSerializer.ReadJSONClassInstance <PlayerQueueStats>(reader); } reader.ReadArrayEnd(); return(valArray); } else if (fieldType == typeof(InputControl[])) { reader.ReadArrayStart(); List <InputControl> valList = new List <InputControl>(); while (true) { try { valList.Add(GenericSerializer.ReadJSONClassInstance <InputControl>(reader)); } catch { break; } } reader.ReadArrayEnd(); return(valList.ToArray()); } else if (fieldType == typeof(Artifact)) { return(Jboy.Json.ReadObject <Artifact>(reader)); } else if (fieldType == typeof(ArtifactSlot)) { return(Jboy.Json.ReadObject <ArtifactSlot>(reader)); } else if (fieldType == typeof(ArtifactTree)) { return(Jboy.Json.ReadObject <ArtifactTree>(reader)); } else if (fieldType == typeof(ArtifactInventory)) { return(Jboy.Json.ReadObject <ArtifactInventory>(reader)); } else if (fieldType == typeof(List <ItemSlot>)) { return(Jboy.Json.ReadObject <List <ItemSlot> >(reader)); } else if (fieldType == typeof(TimeStamp)) { return(Jboy.Json.ReadObject <TimeStamp>(reader)); } else if (fieldType == typeof(SkillBuild)) { return(Jboy.Json.ReadObject <SkillBuild>(reader)); //} else if(fieldType == typeof(WeaponBuild)) { // return Jboy.Json.ReadObject<WeaponBuild>(reader); //} else if(fieldType == typeof(AttunementBuild)) { // return Jboy.Json.ReadObject<AttunementBuild>(reader); } else if (fieldType == typeof(WeaponBuild[])) { return(Jboy.Json.ReadObject <WeaponBuild[]>(reader)); } else if (fieldType == typeof(AttunementBuild[])) { return(Jboy.Json.ReadObject <AttunementBuild[]>(reader)); } else if (fieldType == typeof(Guild)) { return(GenericSerializer.ReadJSONClassInstance <Guild>(reader)); } else if (fieldType == typeof(GuildMember)) { return(GenericSerializer.ReadJSONClassInstance <GuildMember>(reader)); } else if (fieldType == typeof(GuildMember[])) { return(Jboy.Json.ReadObject <GuildMember[]>(reader)); } else if (fieldType == typeof(List <string>)) { return(Jboy.Json.ReadObject <List <string> >(reader)); } else if (fieldType == typeof(List <Friend>)) { return(Jboy.Json.ReadObject <List <Friend> >(reader)); } else if (fieldType == typeof(List <FriendsGroup>)) { return(Jboy.Json.ReadObject <List <FriendsGroup> >(reader)); } else if (fieldType == typeof(Texture2D)) { return(Texture2DSerializer.JsonDeserializer(reader)); } else { LogManager.General.LogError("Unknown field type for GenericSerializer.ReadJSONValue: " + fieldType); return((int)(reader.ReadNumber())); } }
// Reader public static object JsonDeserializer(Jboy.JsonReader reader) { reader.ReadNull(); return(null); //new Texture2D(64, 64); }