-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathXML.cs
74 lines (65 loc) · 2.08 KB
/
XML.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using System.IO;
namespace Brake
{
public class IPAInfo
{
public string AppName;
public string AppVersion;
public string AppBundle;
public string Location;
public string BinaryLocation;
public string IPALocation;
public string IPALocationOnDevice;
public Dictionary<string, object> iTunesMetadata;
}
public class Configuration
{
public string host;
public string Password;
public int port;
public string ipaDir;
}
public class Container
{
private static Container container;
public static Container getContainer()
{
if (container == null)
{
try
{
XmlSerializer serializer = new XmlSerializer(typeof(Container));
StreamReader reader = new StreamReader("Brake.xml");
container = (Container)serializer.Deserialize(reader);
reader.Close();
}
catch (System.IO.FileNotFoundException)
{
Console.WriteLine("==============================");
Console.WriteLine("Looks like you're new, please fill in the details of your device");
container = new Container();
}
}
return container;
}
public List<IPAInfo> IPAItems;
public Configuration Config;
public Container()
{
IPAItems = new List<IPAInfo>();
Config = new Configuration();
}
public void SaveXML()
{
using (StreamWriter writer = new StreamWriter("Brake.xml"))
{
XmlSerializer serializer = new XmlSerializer(typeof(Container));
serializer.Serialize(writer, this);
Console.WriteLine("serializing data");
}
}
}
}