Пример #1
0
        public static Value FromProto(Com.DigitalAsset.Ledger.Api.V1.Value value)
        {
            switch (value.SumCase)
            {
            case Com.DigitalAsset.Ledger.Api.V1.Value.SumOneofCase.Record:
                return(Record.FromProto(value.Record));

            case Com.DigitalAsset.Ledger.Api.V1.Value.SumOneofCase.Variant:
                return(Variant.FromProto(value.Variant));

            case Com.DigitalAsset.Ledger.Api.V1.Value.SumOneofCase.Enum:
                return(DamlEnum.FromProto(value.Enum));

            case Com.DigitalAsset.Ledger.Api.V1.Value.SumOneofCase.ContractId:
                return(new ContractId(value.ContractId));

            case Com.DigitalAsset.Ledger.Api.V1.Value.SumOneofCase.List:
                return(DamlList.FromProto(value.List));

            case Com.DigitalAsset.Ledger.Api.V1.Value.SumOneofCase.Int64:
                return(new Int64(value.Int64));

            case Com.DigitalAsset.Ledger.Api.V1.Value.SumOneofCase.Numeric:
                return(Numeric.FromProto(value.Numeric));

            case Com.DigitalAsset.Ledger.Api.V1.Value.SumOneofCase.Text:
                return(new Text(value.Text));

            case Com.DigitalAsset.Ledger.Api.V1.Value.SumOneofCase.Timestamp:
                return(new Timestamp(value.Timestamp));

            case Com.DigitalAsset.Ledger.Api.V1.Value.SumOneofCase.Party:
                return(new Party(value.Party));

            case Com.DigitalAsset.Ledger.Api.V1.Value.SumOneofCase.Bool:
                return(new Bool(value.Bool));

            case Com.DigitalAsset.Ledger.Api.V1.Value.SumOneofCase.Unit:
                return(Unit.Instance);

            case Com.DigitalAsset.Ledger.Api.V1.Value.SumOneofCase.Date:
                return(new Date(value.Date));

            case Com.DigitalAsset.Ledger.Api.V1.Value.SumOneofCase.Optional:
                return(DamlOptional.FromProto(value.Optional));

            case Com.DigitalAsset.Ledger.Api.V1.Value.SumOneofCase.Map:
                return(DamlTextMap.FromProto(value.Map));

            case Com.DigitalAsset.Ledger.Api.V1.Value.SumOneofCase.GenMap:
                return(DamlGenMap.FromProto(value.GenMap));

            case Com.DigitalAsset.Ledger.Api.V1.Value.SumOneofCase.None:
                throw new SumNotSetException(value);

            default:
                throw new UnknownValueException(value);
            }
        }
Пример #2
0
        private void ConvertThroughProto(ContractId source)
        {
            Com.DigitalAsset.Ledger.Api.V1.Value protoValue = source.ToProto();
            var maybe = Value.FromProto(protoValue).AsContractId();

            Assert.AreEqual(typeof(Some <ContractId>), maybe.GetType());
            Assert.IsTrue(source == (Some <ContractId>)maybe);
        }
Пример #3
0
        private void ConvertThroughProto(Unit source)
        {
            Com.DigitalAsset.Ledger.Api.V1.Value protoValue = source.ToProto();
            var maybe = Value.FromProto(protoValue).AsUnit();

            Assert.AreEqual(typeof(Some <Unit>), maybe.GetType());
            Assert.IsTrue(source == ((Some <Unit>)maybe).Content);
        }
Пример #4
0
 public InvalidKeyValue(Com.DigitalAsset.Ledger.Api.V1.Value value)
     : base($"invalid key value, expected TEXT, found {value.SumCase.ToString()}")
 {
 }
Пример #5
0
 public UnknownValueException(Com.DigitalAsset.Ledger.Api.V1.Value value)
     : base($"value unknown {value}")
 {
 }
Пример #6
0
 public SumNotSetException(Com.DigitalAsset.Ledger.Api.V1.Value value)
     : base($"Sum not set for value {value}")
 {
 }