Ejemplo n.º 1
0
        private void ConvertThroughProto(TransactionTree source)
        {
            Com.Daml.Ledger.Api.V1.TransactionTree protoValue = source.ToProto();
            TransactionTree target = TransactionTree.FromProto(protoValue);

            Assert.True(source == target);
        }
Ejemplo n.º 2
0
        public Com.Daml.Ledger.Api.V1.TransactionTree ToProto()
        {
            var transactionTree = new Com.Daml.Ledger.Api.V1.TransactionTree {
                TransactionId = TransactionId, CommandId = CommandId, WorkflowId = WorkflowId,
                EffectiveAt   = Google.Protobuf.WellKnownTypes.Timestamp.FromDateTimeOffset(EffectiveAt), Offset = Offset
            };

            transactionTree.EventsById.Add(EventsById.Select(p => (p.Key, p.Value.ToProtoTreeEvent())).ToDictionary(p => p.Item1, p => p.Item2));
            transactionTree.RootEventIds.AddRange(RootEventIds);

            return(transactionTree);
        }
Ejemplo n.º 3
0
        public static TransactionTree FromProto(Com.Daml.Ledger.Api.V1.TransactionTree tree)
        {
            var eventsById = tree.EventsById.Values.Select(e => (e.Created?.EventId ?? e.Exercised?.EventId, TreeEvent.FromProtoTreeEvent(e))).ToDictionary(p => p.Item1, p => p.Item2);

            return(new TransactionTree(tree.TransactionId, tree.CommandId, tree.WorkflowId, tree.EffectiveAt.ToDateTimeOffset(), eventsById, tree.RootEventIds.ToList(), tree.Offset));
        }