-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProject.cs
82 lines (64 loc) · 2.01 KB
/
Project.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
75
76
77
78
79
80
81
82
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.IO;
namespace Merthsoft.TokenIDE.Project {
public class ProjectFile {
[XmlAttribute("path")]
public string Path { get; set; }
[XmlAttribute("output")]
public string Output { get; set; }
public override string ToString() {
return new FileInfo(Path).GetFileName();
}
}
public class PojectSection {
[XmlArray("Programs"), XmlArrayItem("File")]
public List<ProjectFile> Programs { get; set; }
[XmlArray("AppVars"), XmlArrayItem("File")]
public List<ProjectFile> AppVars { get; set; }
public PojectSection() {
Programs = new List<ProjectFile>();
AppVars = new List<ProjectFile>();
}
}
[XmlRoot("TokensProject", Namespace=TokensProject.SCHEMA)]
public class TokensProject {
public const string SCHEMA = "http://merthsoft.com/TokensProject";
[XmlIgnore]
public string FileName { get; set; }
[XmlAttribute("name")]
public string Name { get; set; }
[XmlAttribute("baseDirectory")]
public string BaseDirectory { get; set; }
[XmlAttribute("outDirectory")]
public string OutDirectory { get; set; }
[XmlElement("RAM")]
public PojectSection Ram { get; set; }
[XmlElement("Archive")]
public PojectSection Archive { get; set; }
public TokensProject() {
Ram = new PojectSection();
Archive = new PojectSection();
}
public void Save(string fileName = null) {
if (fileName != null) {
FileName = fileName;
}
XmlSerializer serializer = new XmlSerializer(typeof(TokensProject));
using (StreamWriter fs = new StreamWriter(FileName, false, Encoding.Unicode)) {
serializer.Serialize(fs, this);
}
}
public static TokensProject Open(string fileName) {
XmlSerializer serializer = new XmlSerializer(typeof(TokensProject));
using (FileStream fs = new FileStream(fileName, FileMode.Open)) {
TokensProject project = (TokensProject)serializer.Deserialize(fs);
project.FileName = fileName;
return project;
}
}
}
}