public FilesEventPersistence( ILog log, IJsonSerializer jsonSerializer, IFilesEventStoreConfiguration configuration, IFilesEventLocator filesEventLocator) { _log = log; _jsonSerializer = jsonSerializer; _filesEventLocator = filesEventLocator; _logFilePath = Path.Combine(configuration.StorePath, "Log.store"); if (File.Exists(_logFilePath)) { var json = File.ReadAllText(_logFilePath); var eventStoreLog = _jsonSerializer.Deserialize<EventStoreLog>(json); _globalSequenceNumber = eventStoreLog.GlobalSequenceNumber; _eventLog = eventStoreLog.Log ?? new Dictionary<long, string>(); if (_eventLog.Count != _globalSequenceNumber) { eventStoreLog = RecreateEventStoreLog(configuration.StorePath); _globalSequenceNumber = eventStoreLog.GlobalSequenceNumber; _eventLog = eventStoreLog.Log; } } else { _eventLog = new Dictionary<long, string>(); } }
public FilesEventPersistence( ILog log, IJsonSerializer jsonSerializer, IFilesEventStoreConfiguration configuration, IFilesEventLocator filesEventLocator) { _log = log; _jsonSerializer = jsonSerializer; _filesEventLocator = filesEventLocator; _logFilePath = Path.Combine(configuration.StorePath, "Log.store"); if (File.Exists(_logFilePath)) { var json = File.ReadAllText(_logFilePath); var eventStoreLog = _jsonSerializer.Deserialize <EventStoreLog>(json); _globalSequenceNumber = eventStoreLog.GlobalSequenceNumber; _eventLog = eventStoreLog.Log ?? new Dictionary <long, string>(); if (_eventLog.Count != _globalSequenceNumber) { eventStoreLog = RecreateEventStoreLog(configuration.StorePath); _globalSequenceNumber = eventStoreLog.GlobalSequenceNumber; _eventLog = eventStoreLog.Log; } } else { _eventLog = new Dictionary <long, string>(); } }