Exemplo n.º 1
0
        /// <summary>
        /// Exports the given data into a JSON file.
        /// </summary>
        public static void ExportToJson(string path, ComputerConfiguration configuration, List<BenchmarkTest> benchmarks, ReportType type)
        {
            List<JsonObjectCollection> collection = new List<JsonObjectCollection>();

            collection.Add(ConvertToJson(configuration));

            foreach (var benchmark in benchmarks)
                collection.Add(ConvertToJson(benchmark, type));

            using (FileStream stream = new FileStream(path, FileMode.Create, FileAccess.Write))
            {
                StreamWriter writer = new StreamWriter(stream);

                JsonObjectCollection json = new JsonObjectCollection(collection);
                json.WriteTo(writer);

                writer.Flush();
            }
        }