public static Value FromProto(Com.Daml.Ledger.Api.V1.Value value) { switch (value.SumCase) { case Com.Daml.Ledger.Api.V1.Value.SumOneofCase.Record: return(Record.FromProto(value.Record)); case Com.Daml.Ledger.Api.V1.Value.SumOneofCase.Variant: return(Variant.FromProto(value.Variant)); case Com.Daml.Ledger.Api.V1.Value.SumOneofCase.Enum: return(DamlEnum.FromProto(value.Enum)); case Com.Daml.Ledger.Api.V1.Value.SumOneofCase.ContractId: return(new ContractId(value.ContractId)); case Com.Daml.Ledger.Api.V1.Value.SumOneofCase.List: return(DamlList.FromProto(value.List)); case Com.Daml.Ledger.Api.V1.Value.SumOneofCase.Int64: return(new Int64(value.Int64)); case Com.Daml.Ledger.Api.V1.Value.SumOneofCase.Numeric: return(Numeric.FromProto(value.Numeric)); case Com.Daml.Ledger.Api.V1.Value.SumOneofCase.Text: return(new Text(value.Text)); case Com.Daml.Ledger.Api.V1.Value.SumOneofCase.Timestamp: return(new Timestamp(value.Timestamp)); case Com.Daml.Ledger.Api.V1.Value.SumOneofCase.Party: return(new Party(value.Party)); case Com.Daml.Ledger.Api.V1.Value.SumOneofCase.Bool: return(new Bool(value.Bool)); case Com.Daml.Ledger.Api.V1.Value.SumOneofCase.Unit: return(Unit.Instance); case Com.Daml.Ledger.Api.V1.Value.SumOneofCase.Date: return(new Date(value.Date)); case Com.Daml.Ledger.Api.V1.Value.SumOneofCase.Optional: return(DamlOptional.FromProto(value.Optional)); case Com.Daml.Ledger.Api.V1.Value.SumOneofCase.Map: return(DamlTextMap.FromProto(value.Map)); case Com.Daml.Ledger.Api.V1.Value.SumOneofCase.GenMap: return(DamlGenMap.FromProto(value.GenMap)); case Com.Daml.Ledger.Api.V1.Value.SumOneofCase.None: throw new SumNotSetException(value); default: throw new UnknownValueException(value); } }
private void ConvertThroughProto(Variant source) { Com.Daml.Ledger.Api.V1.Value protoValue = source.ToProto(); var maybe = Value.FromProto(protoValue).AsVariant(); maybe.Should().BeOfType <Some <Variant> >(); Assert.True(source == (Some <Variant>)maybe); }
private void ConvertThroughProto(DamlOptional source) { Com.Daml.Ledger.Api.V1.Value protoValue = source.ToProto(); var maybe = Value.FromProto(protoValue).AsOptional(); maybe.Should().BeOfType <Some <DamlOptional> >(); Assert.True(source == (Some <DamlOptional>)maybe); }
public InvalidKeyValue(Com.Daml.Ledger.Api.V1.Value value) : base($"invalid key value, expected TEXT, found {value.SumCase.ToString()}") { }
public UnknownValueException(Com.Daml.Ledger.Api.V1.Value value) : base($"value unknown {value}") { }
public SumNotSetException(Com.Daml.Ledger.Api.V1.Value value) : base($"Sum not set for value {value}") { }