Exemplo n.º 1
0
        protected TSnapshot LoadSnapshot <TSnapshot>(FileSystemConnectionContext connectionContext)
            where TSnapshot : Snapshot
        {
            _fileSystem.CreateDirectoryIfItDoesntExist(connectionContext.DataRoot);

            var contractName = Activator.CreateInstance <TSnapshot>().ContractName;
            var info         = _fileSystem.GetFileInfos(connectionContext.DataRoot, $"snapshot--{contractName}-*.json")
                               .OrderByDescending(item => item.CreationTimeUtc)
                               .FirstOrDefault();

            if (info != null)
            {
                var contents = _fileSystem.ReadAllText(info.FullName);
                return(JsonConvert.DeserializeObject <TSnapshot>(contents));
            }

            return(null);
        }
Exemplo n.º 2
0
        public int GetCurrentDay(FileSystemConnectionContext connectionContext)
        {
            var files = _fileSystemWrapper.GetFileInfos(connectionContext.DataRoot, "event--advance-day-*.json");

            return(files != null ? files.Count : 0);
        }