public override Format.Schema.Op Serialize() { Format.Schema.Op result = new Format.Schema.Op(); Format.Schema.OpUnary opUnary = new Format.Schema.OpUnary(); switch (this.op) { case UnaryOp.Negate: opUnary.Kind = Format.Schema.OpUnary.Types.Kind.Negate; break; case UnaryOp.Parens: opUnary.Kind = Format.Schema.OpUnary.Types.Kind.Parens; break; case UnaryOp.Length: opUnary.Kind = Format.Schema.OpUnary.Types.Kind.Length; break; } result.Unary = opUnary; return(result); }
static public Either <FormatError, Op> DeserializeV1(Format.Schema.OpUnary op) { return(op.Kind switch { Format.Schema.OpUnary.Types.Kind.Negate => new Op.Unary(UnaryOp.Negate), Format.Schema.OpUnary.Types.Kind.Parens => new Op.Unary(UnaryOp.Parens), Format.Schema.OpUnary.Types.Kind.Length => new Op.Unary(UnaryOp.Length), _ => new DeserializationError("invalid unary operation"), });