コード例 #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);
        }
コード例 #2
0
ファイル: DayRepo.cs プロジェクト: djohnson001/GildedRose
        public int GetCurrentDay(FileSystemConnectionContext connectionContext)
        {
            var files = _fileSystemWrapper.GetFileInfos(connectionContext.DataRoot, "event--advance-day-*.json");

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