-
Notifications
You must be signed in to change notification settings - Fork 1
/
AutoBuild_config.cs
225 lines (197 loc) · 7.04 KB
/
AutoBuild_config.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
using System;
using System.Collections.ObjectModel;
using System.IO;
using System.Xml.Serialization;
using System.Collections.Generic;
using CoApp.Toolkit.Collections;
using CoApp.Toolkit.Extensions;
namespace AutoBuilder
{
public delegate void MasterConfigChangeHandler(AutoBuild_config sender);
[XmlRoot(ElementName = "AutoBuild_config", Namespace = "http://coapp.org/automation/build")]
public class AutoBuild_config
{
private const string DEFAULTROOT = @"C:\AutoBuild\Packages";
private const string DEFAULTOUTPUT = @"C:\output";
#region XML Serialization methods
/*
public string ToXML()
{
XmlSerializer S = new XmlSerializer(typeof(AutoBuild_config));
StringWriter TW = new StringWriter();
S.Serialize(TW, this);
return TW.ToString();
}
public static string ToXML(ProjectData obj)
{
XmlSerializer S = new XmlSerializer(typeof(AutoBuild_config));
StringWriter TW = new StringWriter();
S.Serialize(TW, obj);
return TW.ToString();
}
public static AutoBuild_config FromXML(string XMLinput)
{
XmlSerializer S = new XmlSerializer(typeof(AutoBuild_config));
StringReader SR = new StringReader(XMLinput);
return (AutoBuild_config)S.Deserialize(SR);
}
public static AutoBuild_config FromXML(Stream XMLinput)
{
XmlSerializer S = new XmlSerializer(typeof(AutoBuild_config));
return (AutoBuild_config)S.Deserialize(XMLinput);
}
*/
#endregion
//Actual class data
public event MasterConfigChangeHandler Changed;
[NotPersistable]
public bool DefaultCleanRepo
{
get { return _DefaultCleanRepo; }
set
{
ChangedEvent();
_DefaultCleanRepo = value;
}
}
[Persistable]
private bool _DefaultCleanRepo;
[NotPersistable]
public bool UseGithubListener
{
get { return _UseGithubListener; }
set
{
ChangedEvent();
_UseGithubListener = value;
}
}
[Persistable]
private bool _UseGithubListener;
[NotPersistable]
public string ProjectRoot
{
get { return _ProjectRoot; }
set
{
ChangedEvent();
_ProjectRoot = value;
}
}
[Persistable]
private string _ProjectRoot;
[NotPersistable]
public string OutputStore
{
get { return _OutputStore; }
set
{
ChangedEvent();
_OutputStore = value;
}
}
[Persistable]
private string _OutputStore;
[NotPersistable]
public int MaxJobs
{
get { return _MaxJobs; }
set
{
ChangedEvent();
_MaxJobs = value;
}
}
[Persistable]
private int _MaxJobs;
[NotPersistable]
public int PreTriggerWait
{
get { return _PreTriggerWait; }
set
{
ChangedEvent();
_PreTriggerWait = value;
}
}
[Persistable]
private int _PreTriggerWait;
// [XmlArray(IsNullable = false)]
[Persistable]
public XDictionary<string, VersionControl> VersionControlList { get; private set; }
// [XmlArray(IsNullable = false)]
[Persistable]
public XDictionary<string, List<string>> DefaultCommands { get; private set; }
// [XmlArray(IsNullable = false)]
[Persistable]
public XDictionary<string, CommandScript> Commands { get; private set; }
[Persistable]
public ObservableCollection<string> DefaultRefs { get; private set; }
private void ChangedEvent()
{
if (Changed != null)
Changed(this);
}
private void DefaultCommandsChanged(IDictionary<string, List<string>> dict)
{
ChangedEvent();
}
private void VCSChanged(IDictionary<string, VersionControl> dict)
{
ChangedEvent();
}
private void CommandsChanged(IDictionary<string, CommandScript> dict)
{
ChangedEvent();
}
private void CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
ChangedEvent();
}
//Default constructor. Always good to have one of these.
public AutoBuild_config()
{
_DefaultCleanRepo = true;
_UseGithubListener = true;
_ProjectRoot = DEFAULTROOT;
_OutputStore = DEFAULTOUTPUT;
_PreTriggerWait = 60 * 1000;
_MaxJobs = 4;
VersionControlList = new XDictionary<string, VersionControl>();
DefaultCommands = new XDictionary<string, List<string>>();
Commands = new XDictionary<string, CommandScript>();
DefaultRefs = new ObservableCollection<string>();
VersionControlList.Changed += VCSChanged;
DefaultCommands.Changed += DefaultCommandsChanged;
Commands.Changed += CommandsChanged;
DefaultRefs.CollectionChanged += CollectionChanged;
}
//A copy constructor, because I'm always annoyed when I can't find one.
public AutoBuild_config(AutoBuild_config source)
{
_DefaultCleanRepo = source.DefaultCleanRepo;
_UseGithubListener = source.UseGithubListener;
_ProjectRoot = source.ProjectRoot;
_OutputStore = source.OutputStore;
_PreTriggerWait = source.PreTriggerWait;
_MaxJobs = source.MaxJobs;
VersionControlList = new XDictionary<string, VersionControl>(source.VersionControlList);
DefaultCommands = new XDictionary<string, List<string>>(source.DefaultCommands);
Commands = new XDictionary<string, CommandScript>(source.Commands);
DefaultRefs = new ObservableCollection<string>(source.DefaultRefs);
VersionControlList.Changed += VCSChanged;
DefaultCommands.Changed += DefaultCommandsChanged;
Commands.Changed += CommandsChanged;
DefaultRefs.CollectionChanged += CollectionChanged;
}
/*
//And a stream constructor in case I ever feel I need it.
public AutoBuild_config(Stream XMLinput) : this(FromXML(XMLinput))
{
VersionControlList.Changed += VCSChanged;
DefaultCommands.Changed += DefaultCommandsChanged;
Commands.Changed += CommandsChanged;
}
*/
}
}