static public Either <Errors.FormatError, Predicate> DeserializeV1(Format.Schema.PredicateV1 predicate) { IList <ID> ids = new List <ID>(); foreach (Format.Schema.IDV1 id in predicate.Ids) { Either <Errors.FormatError, ID> res = ID.DeserializeEnumV1(id); if (res.IsLeft) { return(res.Left); } else { ids.Add(res.Get()); } } return(new Predicate(predicate.Name, ids)); }
static public Either <Errors.FormatError, ID> DeserializeV1(Format.Schema.IDV1 id) { if (id.Set == null) { return(new Errors.DeserializationError("invalid ID kind, expected set")); } else { HashSet <ID> values = new HashSet <ID>(); Format.Schema.IDSet s = id.Set; foreach (Format.Schema.IDV1 l in s.Set) { Either <Errors.FormatError, ID> res = ID.DeserializeEnumV1(l); if (res.IsLeft) { return(res.Left); } else { ID value = res.Right; if (value is Variable) { return(new Errors.DeserializationError("sets cannot contain variables")); } values.Add(value); } } if (values.Count == 0) { return(new Errors.DeserializationError("invalid Set value")); } else { return(new Set(values)); } } }