public static void RegisterDataIdentifier( StatisticsDataIdentifier value, StatisticsDataIdentifier parent) { if (parent == null) { parent = StatisticsDataLogger._rootData.Identifier; } StatisticsDataLogger.StatData statData = new StatisticsDataLogger.StatData(value, StatisticsDataLogger._logTypes[parent.UniqueId]); StatisticsDataLogger._logTypes.Add(value.UniqueId, statData); }
public StatData(StatisticsDataIdentifier id, StatisticsDataLogger.StatData parent) { this.Identifier = id; this.Parent = parent; this.Children = new List <StatisticsDataLogger.StatData>(); this.Details = new List <string>(); if (this.Parent != null) { this.Parent.Children.Add(this); } this.Number = 0; }
public static void ClearLogs(StatisticsDataIdentifier clearCategory = null) { StatisticsDataLogger.StatData statData = StatisticsDataLogger._rootData; if (clearCategory != null) { statData = StatisticsDataLogger._logTypes[clearCategory.UniqueId]; } statData.Clear(); while (File.Exists(StatisticsDataLogger.GetFileName())) { ++StatisticsDataLogger._versionNo; } }
public static void AddStat(StatisticsDataIdentifier id, int amount, string detail) { if (!StatisticsDataLogger._logTypes.ContainsKey(id.UniqueId)) { return; } StatisticsDataLogger.StatData statData = StatisticsDataLogger._logTypes[id.UniqueId]; if (detail != null) { statData.Details.Add(detail); } for (; statData != null; statData = statData.Parent) { statData.Number += amount; } }
public static void Save(StatisticsDataIdentifier mask = null, string header = "") { using (StreamWriter file = new StreamWriter(StatisticsDataLogger.GetFileName())) { file.WriteLine("Application Time: " + (DateTime.Now - StatisticsDataLogger._applicationStartTime).ToString("G")); file.WriteLine("------------------------------------------"); file.WriteLine(header); file.WriteLine("------------------------------------------"); file.WriteLine("------------------------------------------"); if (mask != null) { StatisticsDataLogger.WriteToFile(file, StatisticsDataLogger._logTypes[mask.UniqueId], 0); } else { StatisticsDataLogger.WriteToFile(file, StatisticsDataLogger._rootData, 0); } } }