Exemplo n.º 1
0
        public Com.DigitalAsset.Ledger.Api.V1.Record ToProtoRecord()
        {
            Com.DigitalAsset.Ledger.Api.V1.Record record = new Com.DigitalAsset.Ledger.Api.V1.Record();

            RecordId.IfPresent(recordId => record.RecordId = recordId.ToProto());
            record.Fields.Add(from f in Fields select f.ToProto());

            return(record);
        }
Exemplo n.º 2
0
        public static Record FromProto(Com.DigitalAsset.Ledger.Api.V1.Record record)
        {
            var fields = record.Fields.Select(Field.FromProto);

            var fieldsMap = fields.Where(f => f.Label.IsPresent).Select(f => (f.Label.Reduce(string.Empty), f.Value)).ToDictionary(p => p.Item1, p => p.Item2);

            if (record.RecordId != null)
            {
                return(new Record(Identifier.FromProto(record.RecordId), fields, fieldsMap));
            }

            return(new Record(None.Value, fields, fieldsMap));
        }