public ValidationNode Validate(ISerializationManager serializationManager, ValueDataNode node, IDependencyCollection dependencies, ISerializationContext?context = null) { if (!VectorSerializerUtility.TryParseArgs(node.Value, 2, out var args)) { throw new InvalidMappingException($"Could not parse {nameof(Vector2)}: '{node.Value}'"); } return(float.TryParse(args[0], NumberStyles.Any, CultureInfo.InvariantCulture, out _) && float.TryParse(args[1], NumberStyles.Any, CultureInfo.InvariantCulture, out _) ? new ValidatedValueNode(node) : new ErrorNode(node, "Failed parsing values for Vector2.")); }
public DeserializationResult Read(ISerializationManager serializationManager, ValueDataNode node, IDependencyCollection dependencies, bool skipHook, ISerializationContext?context = null) { if (!VectorSerializerUtility.TryParseArgs(node.Value, 2, out var args)) { throw new InvalidMappingException($"Could not parse {nameof(Vector2)}: '{node.Value}'"); } var x = float.Parse(args[0], CultureInfo.InvariantCulture); var y = float.Parse(args[1], CultureInfo.InvariantCulture); var vector = new Vector2(x, y); return(new DeserializedValue <Vector2>(vector)); }