public static Object _ReadValue(Type ValueType, JsonReader Reader, MudObject Owner) { Object r = null; if (Reader.TokenType == JsonToken.String) { r = Reader.Value.ToString(); Reader.Read(); } else if (Reader.TokenType == JsonToken.Integer) { r = Convert.ToInt32(Reader.Value.ToString()); Reader.Read(); } else if (Reader.TokenType == JsonToken.Boolean) { r = Convert.ToBoolean(Reader.Value.ToString()); Reader.Read(); } else { PersistentValueSerializer serializer = null; if (ValueType != null && PersistentValueSerializer.GlobalSerializers.TryGetValue(ValueType.Name, out serializer)) { return(serializer.ReadValue(ValueType, Reader, Owner)); } else if (Reader.TokenType == JsonToken.StartObject) { Reader.Read(); if (Reader.TokenType != JsonToken.PropertyName || Reader.Value.ToString() != "$type") { throw new InvalidOperationException(); } Reader.Read(); if (!PersistentValueSerializer.GlobalSerializers.TryGetValue(Reader.Value.ToString(), out serializer)) { throw new InvalidOperationException(); } Reader.Read(); Reader.Read(); r = serializer.ReadValue(ValueType, Reader, Owner); Reader.Read(); } else { throw new InvalidOperationException(); } } return(r); }
public Object ReadValue(Type ValueType, JsonReader Reader, MudObject Owner) { if (Serializer != null) { return(Serializer.ReadValue(ValueType, Reader, Owner)); } return(_ReadValue(ValueType, Reader, Owner)); }