public virtual VPackParser RegisterDeserializer( string attribute, ValueType type, IVPackJsonDeserializer deserializer) { IDictionary <ValueType, IVPackJsonDeserializer> byName = this.deserializersByName[attribute]; if (byName == null) { byName = new Dictionary <ValueType, IVPackJsonDeserializer>(); this.deserializersByName[attribute] = byName; } byName[type] = deserializer; return(this); }
private IVPackJsonDeserializer GetDeserializer(string attribute, ValueType type) { IVPackJsonDeserializer deserializer = null; IDictionary <ValueType, IVPackJsonDeserializer> byName = this.deserializersByName[attribute]; if (byName != null) { deserializer = byName[type]; } if (deserializer == null) { deserializer = this.deserializers[type]; } return(deserializer); }
public virtual VPackParser RegisterDeserializer(ValueType type, IVPackJsonDeserializer deserializer) { this.deserializers[type] = deserializer; return(this); }
/// <exception cref="VPackException"/> private void Parse( VPackSlice parent, string attribute, VPackSlice value, StringBuilder json, bool includeNullValues) { IVPackJsonDeserializer deserializer = null; if (attribute != null) { AppendField(attribute, json); deserializer = this.GetDeserializer(attribute, value.Type()); } if (deserializer != null) { deserializer.deserialize(parent, attribute, value, json); } else { if (value.IsObject) { this.ParseObject(value, json, includeNullValues); } else { if (value.IsArray) { this.ParseArray(value, json, includeNullValues); } else { if (value.IsBoolean) { json.Append(value.AsBoolean); } else { if (value.IsString) { json.Append(JsonConvert.ToString(value.AsString)); } else { if (value.IsNumber) { json.Append(value.AsNumber); } else { if (value.IsNull) { json.Append(NULL); } else { json.Append(JsonConvert.ToString(NON_REPRESENTABLE_TYPE)); } } } } } } } }