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());
        }
Example #2
0
        public async Task <int> OnExecuteAsync()
        {
            var pattern = string.Empty;

            if (Name != "*" && !string.IsNullOrEmpty(Name))
            {
                pattern = Name;
            }

            foreach (var replayPath in _replayLocator.GetReplayPaths(pattern))
            {
                Logger.Information($"Processing: {replayPath}");
                await _replayLogGenerator.GenerateReplayLog(replayPath);
            }

            return(0);
        }