Beispiel #1
0
            public override Format.Schema.IDV1 Serialize()
            {
                Format.Schema.IDSet s = new Format.Schema.IDSet();
                s.Set.AddRange(this.Value.Select(l => l.Serialize()));

                return(new Format.Schema.IDV1()
                {
                    Set = s
                });
            }
Beispiel #2
0
            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));
                    }
                }
            }