private void ReadStatistics() { try { IEnumerable <string> lines = from line in File.ReadLines(StatFile) where !string.IsNullOrEmpty(line) select line; foreach (string line in lines) { IStatsData stats = ParseLine(line.Trim()); stats.RecordTime = DateTime.Now; stats.GameFileID = GameFile.GameFileID.Value; if (!m_statistics.Contains(stats)) { m_statistics.Add(stats); NewStastics?.Invoke(this, new NewStatisticsEventArgs(stats)); } } } catch (FileNotFoundException) { //m_errors.Add(string.Format("The file {0} was not found and could not be parsed.", ex.FileName)); } }
private void HandleStatsData(StatsData statsData) { statsData.GameFileID = GameFile.GameFileID.Value; if (!m_statistics.Contains(statsData)) { m_statistics.Add(statsData); NewStastics?.Invoke(this, new NewStatisticsEventArgs(statsData)); } }
private void ReadStatistics() { try { string text = GetCleanedFileText(); MatchCollection matches = Regex.Matches(text, m_statRegex, RegexOptions.Singleline); foreach (Match match in matches) { IStatsData stats = null; if (match.Success) { stats = ParseLine(match.Value); } if (stats != null) { stats.RecordTime = DateTime.Now; stats.GameFileID = GameFile.GameFileID.Value; //Revived monsters adds to kill count if (stats.KillCount > stats.TotalKills) { stats.KillCount = stats.TotalKills; } if (!m_statistics.Contains(stats)) { m_statistics.Add(stats); NewStastics?.Invoke(this, new NewStatisticsEventArgs(stats)); } } } } catch (Exception ex) { if (ErrorOnFail) { m_errors.Add(string.Format("Unexpected exception: {0}{1}{2}", ex.Message, Environment.NewLine, ex.StackTrace)); } } }