예제 #1
0
        private bool TrySerializeChanges(UpdateEvent updateEvent, out byte[] changes)
        {
            changes = null;
            if (!updateEvent.Updates.Any() && updateEvent.Deletion == null)
            {
                return(false);
            }

            changes = Protobuf.Serialize(updateEvent);
            return(true);
        }
예제 #2
0
        public async Task <Document> Rebuild(string path, int?bookmark = null)
        {
            var eventsPath = _repositories[path];

            bookmark ??= int.MaxValue;

            var document = new Document();

            await foreach (var record in _repository.ReadRecordsAsync(eventsPath).Take(bookmark.Value))
            {
                var decompressed = await record.Decompress();

                var updateEvent = Protobuf.Deserialize <UpdateEvent>(decompressed);
                await document.Apply(updateEvent);
            }

            return(document);
        }