-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
OutputModel.cs
49 lines (45 loc) · 1.37 KB
/
OutputModel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RevitAddin.DA.Tester.Models
{
public class OutputModel
{
public string VersionName { get; set; }
public string VersionBuild { get; set; }
public DateTime TimeStart { get; set; } = DateTime.UtcNow;
public string Text { get; set; }
public string Reference { get; set; }
public string FrameworkName { get; set; }
#region JsonConvert
private const string JSON_FILE = "output.json";
public OutputModel Load(string jsonPath = JSON_FILE)
{
if (File.Exists(jsonPath))
{
string jsonContents = File.ReadAllText(jsonPath);
return JsonConvert.DeserializeObject<OutputModel>(jsonContents);
}
return this;
}
public string Save(string jsonPath = JSON_FILE)
{
string text = JsonConvert.SerializeObject(this);
using (StreamWriter sw = File.CreateText(jsonPath))
{
sw.WriteLine(text);
sw.Close();
}
return text;
}
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
#endregion
}
}