-
Notifications
You must be signed in to change notification settings - Fork 286
/
ConfigFile.cs
46 lines (43 loc) · 1.09 KB
/
ConfigFile.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml.Serialization;
namespace VersionUpdater
{
public sealed class ConfigFile
{
public List<string> GitSearchPaths { get; set; }
public string NuSpecRootDir { get; set; }
public string SolutionPath { get; set; }
public string InstallerPackageConfigPath { get; set; }
public string ApplyGlobalUpdate { get; set; }
public void Save(string filePath)
{
using (FileStream stream = File.Open(filePath, FileMode.Create))
{
this.Save(stream);
}
}
public void Save(Stream stream)
{
XmlSerializer serializer = new XmlSerializer(typeof(ConfigFile));
serializer.Serialize(stream, this);
}
public static ConfigFile Load(string filePath)
{
ConfigFile result;
using (FileStream stream = File.OpenRead(filePath))
{
result = Load(stream);
}
return result;
}
public static ConfigFile Load(Stream stream)
{
XmlSerializer serializer = new XmlSerializer(typeof(ConfigFile));
return serializer.Deserialize(stream) as ConfigFile;
}
}
}