private void VisitValue( IInputType type, object obj, Action <object> setValue, ISet <object> processed) { if (obj is null) { setValue(null); } else if (type.IsListType()) { VisitList( (ListType)type.ListType(), obj, setValue, processed); } else if (type.IsLeafType()) { VisitLeaf( (INamedInputType)type.NamedType(), obj, setValue, processed); } else if (type.IsInputObjectType()) { VisitInputObject( (InputObjectType)type.NamedType(), obj, setValue, processed); } else { throw new NotSupportedException(); } }
private object DeserializeValue(IInputType type, object value) { if (value is IDictionary <string, object> || value is IList <object> ) { return(_inputTypeConverter.Convert(value, type)); } else if (type.IsLeafType() && type.NamedType() is ISerializableType serializable && serializable.TryDeserialize(value, out object deserialized)) { return(deserialized); } return(value); }
private bool ValueNeedsCleanUp(IInputType type, IValueNode value) { if (type.IsEnumType() && value is StringValueNode) { return(true); } if (type.IsInputObjectType() && type.NamedType() is InputObjectType iot && value is ObjectValueNode ov) { return(ObjectNeedsCleanUp(iot, ov)); } if (type.IsListType() && value is ListValueNode listValue) { return(ListNeedsCleanUp(type.ListType(), listValue)); } return(false); }
public static object ParseLiteral( IInputType sourceType, Type targetType, IValueNode literal) { if (sourceType.IsScalarType() || sourceType.IsEnumType()) { return(ParseScalarType(sourceType, targetType, literal)); } else if (sourceType.IsListType()) { return(ParseListType(sourceType, targetType, literal)); } else if (sourceType.IsInputObjectType() && sourceType.NamedType() is InputObjectType iot) { return(ParseObjectType(iot, targetType, literal)); } throw new NotSupportedException( "The serializer does not support the specified source type."); }
private IValueNode RebuildValue(IInputType type, IValueNode value) { if (type.IsEnumType() || type.IsScalarType()) { return(RebuildScalarValue(type, value)); } if (type.IsListType() && type.ListType() is ListType lt && value is ListValueNode lv) { return(RebuildListValue(lt, lv)); } if (type.IsInputObjectType() && type.NamedType() is InputObjectType iot && value is ObjectValueNode ov) { return(RebuildObjectValue(iot, ov)); } return(value); }