| 1 |
using System; |
| 2 |
using System.IO; |
| 3 |
|
| 4 |
namespace Mono.Documentation.Updater.Statistics |
| 5 |
{ |
| 6 |
public static class StatisticsSaver |
| 7 |
{ |
| 8 |
private const string DefaltStatisticsFileName = "statistics.txt"; |
| 9 |
|
| 10 |
/// <summary> |
| 11 |
/// Save statistics to the file |
| 12 |
/// </summary> |
| 13 |
/// <param name="statisticsCollector">Statistics values which should be saved</param> |
| 14 |
/// <param name="statisticsFilePath">Path to the file where statistics should be saved</param> |
| 15 |
public static void Save(StatisticsCollector statisticsCollector, string statisticsFilePath) |
| 16 |
{ |
| 17 |
if (Directory.Exists(statisticsFilePath)) |
| 18 |
statisticsFilePath = Path.Combine(statisticsFilePath, DefaltStatisticsFileName); |
| 19 |
File.WriteAllText(statisticsFilePath, StatisticsFormatter.Format(statisticsCollector.Storages)); |
| 20 |
Console.WriteLine($"Statistics saved to {statisticsFilePath}"); |
| 21 |
} |
| 22 |
} |
| 23 |
} |