Beispiel #1
0
        private static void WriteToFile(
            StreamWriter file,
            StatisticsDataLogger.StatData data,
            int height)
        {
            string str1 = "";

            for (int index = 0; index < height; ++index)
            {
                str1 += "|  ";
            }
            if (!data.Identifier.IsFiltered && data.Details.Count > 0)
            {
                string str2 = str1 + " -";
                foreach (string detail in data.Details)
                {
                    file.WriteLine(str2 + detail);
                }
            }
            foreach (StatisticsDataLogger.StatData child in data.Children)
            {
                file.WriteLine(str1 + child.Identifier.Description + "  : " + (object)child.Number);
                StatisticsDataLogger.WriteToFile(file, child, height + 1);
            }
        }
Beispiel #2
0
 static StatisticsDataLogger()
 {
     StatisticsDataLogger._logTypes = new Dictionary <uint, StatisticsDataLogger.StatData>();
     StatisticsDataLogger._rootData = new StatisticsDataLogger.StatData(new StatisticsDataIdentifier("LOG"), (StatisticsDataLogger.StatData)null);
     StatisticsDataLogger._logTypes.Add(StatisticsDataLogger._rootData.Identifier.UniqueId, StatisticsDataLogger._rootData);
     StatisticsDataLogger._versionNo = 0;
     StatisticsDataLogger.ClearLogs();
 }
Beispiel #3
0
 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);
 }
Beispiel #4
0
 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;
 }
Beispiel #5
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;
     }
 }
Beispiel #6
0
 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;
     }
 }