コード例 #1
0
        public IReadOnlyCollection <ReplayResource> Get(string pattern = "*")
        {
            var resources = new List <ReplayResource>();

            foreach (var game in _replayLocator.GetReplayPaths(pattern))
            {
                var fileName          = _fileSystem.Path.GetFileNameWithoutExtension(game);
                var folder            = _fileSystem.Path.GetDirectoryName(game);
                var replayLogFilePath = _fileSystem.Path.Combine(folder, fileName + ".log");

                if (_fileSystem.File.Exists(replayLogFilePath))
                {
                    resources.Add(_replayTextReader.GetModel(_fileSystem.File.ReadAllText(replayLogFilePath)));
                }
                else
                {
                    var startIndex = fileName.IndexOf('[');
                    var dateString = fileName.Substring(0, startIndex - 1);
                    var date       = DateTime.ParseExact(dateString, "yyyy-MM-dd HH.mm.ss", null);
                    resources.Add(
                        new ReplayResource(
                            date,
                            "local",
                            false,
                            new List <string>(),
                            string.Empty,
                            string.Empty)
                        );
                }
            }

            return(resources.OrderByDescending(x => x.Date).ToList());
        }
コード例 #2
0
        public IReadOnlyCollection <LocalReplay> Get(string pattern = "*")
        {
            var resources = new List <LocalReplay>();

            foreach (var paths in _localReplayLocator.GetReplayPaths(pattern))
            {
                if (_fileSystem.File.Exists(paths.LogPath))
                {
                    resources.Add(new LocalReplay(
                                      paths,
                                      _replayTextReader.GetModel(_fileSystem.File.ReadAllText(paths.LogPath))));
                }
                else
                {
                    var fileName   = _fileSystem.Path.GetFileNameWithoutExtension(paths.WAgamePath);
                    var startIndex = fileName.IndexOf('[');
                    var dateString = fileName.Substring(0, startIndex - 1);
                    var date       = DateTime.ParseExact(dateString, "yyyy-MM-dd HH.mm.ss", null);
                    resources.Add(
                        new LocalReplay(paths,
                                        new ReplayResource(
                                            date,
                                            false,
                                            new List <Team>(0),
                                            null,
                                            new List <Turn>(0),
                                            string.Empty)
                                        ));
                }
            }

            return(resources.OrderByDescending(x => x.Details.Date).ToList());
        }