public override bool Initialize(string jsonString = null) { if (jsonString == null) { IDictionaryResponse <T, R> mr = (IDictionaryResponse <T, R>) this.Send(_url); this._Success = mr.Success; this._Message = mr.Message; if (this.Success) { this.Process(mr); } return(this.Success); } else { return(false); } }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var response = new GetAutoFollowPatternResponse(); IDictionaryResponse <string, AutoFollowPattern> dictResponse = response; var dict = new Dictionary <string, AutoFollowPattern>(); dictResponse.BackingDictionary = dict; bool checkedError = false; if (reader.TokenType != JsonToken.StartObject) { return(response); } while (reader.Read() && reader.TokenType != JsonToken.EndObject) { var propertyName = (string)reader.Value; if (propertyName == "patterns") { // 6.6 reader.Read(); // opening [ of patterns array while (reader.Read() && reader.TokenType != JsonToken.EndArray) { string name = null; AutoFollowPattern pattern = null; while (reader.Read() && reader.TokenType != JsonToken.EndObject) { propertyName = (string)reader.Value; if (propertyName == "name") { name = reader.ReadAsString(); } else { reader.Read(); pattern = serializer.Deserialize <AutoFollowPattern>(reader); } } dict.Add(name, pattern); } } else if (!checkedError && propertyName == "error") { reader.Read(); response.Error = reader.TokenType == JsonToken.String ? new Error { Reason = (string)reader.Value } : serializer.Deserialize <Error>(reader); } else if (!checkedError && propertyName == "status") { response.StatusCode = reader.ReadAsInt32(); } else { checkedError = true; // 6.5 reader.Read(); // opening { of AutoFollowPattern dict.Add(propertyName, serializer.Deserialize <AutoFollowPattern>(reader)); } } return(response); }
public abstract void Process(IDictionaryResponse <T, R> mr);
public override void Process(IDictionaryResponse <CoinList, CoinListData> mr) { this._Data = mr.Data; }