private static MinoratingServerInformation[] DeserializeFast(Stream stream) { var reader = new JsonTextReader(new StreamReader(stream)); var response = new List <MinoratingServerInformation>(AverageServersCount); var currentProperty = string.Empty; reader.MatchNext(JsonToken.StartArray); while (reader.IsMatchNext(JsonToken.StartObject)) { var entry = new MinoratingServerInformation(); while (reader.Until(JsonToken.EndObject)) { if (!SetToken(reader, ref currentProperty, entry)) { SetMinoratingToken(reader, ref currentProperty, entry); } } response.Add(entry); } return(response.ToArray()); }
private static bool SetMinoratingToken(JsonTextReader reader, ref string currentProperty, MinoratingServerInformation entry) { switch (reader.TokenType) { case JsonToken.Integer: switch (currentProperty) { case "activity": entry.Activity = int.Parse(reader.Value.ToString(), CultureInfo.InvariantCulture); return(true); case "cleanliness": entry.Cleanliness = int.Parse(reader.Value.ToString(), CultureInfo.InvariantCulture); return(true); case "competition": entry.Competition = int.Parse(reader.Value.ToString(), CultureInfo.InvariantCulture); return(true); } break; case JsonToken.Null: switch (currentProperty) { case "grades": // entry.Grades = null; return(true); } break; } return(false); }