public JsonContract ModifyContract(JsonContract contract) { if (contract is JsonDictionaryContract) { var dictionaryContract = contract as JsonDictionaryContract; if (typeof(GeoLocation).IsAssignableFrom(dictionaryContract.DictionaryValueType)) { dictionaryContract.DictionaryKeyResolver = x => x + "$$geo"; } else if (typeof(Attachment).IsAssignableFrom(dictionaryContract.DictionaryValueType)) { dictionaryContract.DictionaryKeyResolver = x => x + "$$attachment"; } else { dictionaryContract.DictionaryKeyResolver = x => TypeSuffix.GetSuffixedFieldName(x, dictionaryContract.DictionaryValueType); } dictionaryContract.Converter = new Dictionary2Find.Json.DictionaryConverter() { PropertyNameDesolver = x => x.Contains('$') ? x.Split('$')[0] : x }; } return(contract); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { Url url = existingValue as Url; string str = (string)null; while (reader.Read()) { if (reader.TokenType.Equals((object)JsonToken.PropertyName)) { str = reader.Value as string; } if (reader.TokenType.Equals((object)JsonToken.String) && str.Equals(TypeSuffix.GetSuffixedFieldName("OriginalString", typeof(string)))) { return((object)new Url(reader.Value.ToString())); } } return((object)url); }