clockwerk-opensim – Blame information for rev 3
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | vero | 1 | #region BSD License |
2 | /* |
||
3 | Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com) |
||
4 | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted |
||
6 | provided that the following conditions are met: |
||
7 | |||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions |
||
9 | and the following disclaimer. |
||
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions |
||
11 | and the following disclaimer in the documentation and/or other materials provided with the |
||
12 | distribution. |
||
13 | * The name of the author may not be used to endorse or promote products derived from this software |
||
14 | without specific prior written permission. |
||
15 | |||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, |
||
17 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
||
19 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
||
20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
||
21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
||
22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
23 | */ |
||
24 | #endregion |
||
25 | |||
26 | using System; |
||
27 | using System.Collections.Generic; |
||
28 | using System.Diagnostics; |
||
29 | using System.Xml; |
||
30 | |||
31 | using Prebuild.Core.Attributes; |
||
32 | using Prebuild.Core.Interfaces; |
||
33 | using Prebuild.Core.Utilities; |
||
34 | |||
35 | namespace Prebuild.Core.Nodes |
||
36 | { |
||
37 | /// <summary> |
||
38 | /// |
||
39 | /// </summary> |
||
40 | [DataNode("Solution")] |
||
41 | [DataNode("EmbeddedSolution")] |
||
42 | [DebuggerDisplay("{Name}")] |
||
43 | public class SolutionNode : DataNode |
||
44 | { |
||
45 | #region Fields |
||
46 | |||
47 | private Guid m_Guid = Guid.NewGuid(); |
||
48 | private string m_Name = "unknown"; |
||
49 | private string m_Path = ""; |
||
50 | private string m_FullPath = ""; |
||
51 | private string m_ActiveConfig; |
||
52 | private string m_Version = "1.0.0"; |
||
53 | |||
54 | private OptionsNode m_Options; |
||
55 | private FilesNode m_Files; |
||
56 | private readonly ConfigurationNodeCollection m_Configurations = new ConfigurationNodeCollection(); |
||
57 | private readonly Dictionary<string, ProjectNode> m_Projects = new Dictionary<string, ProjectNode>(); |
||
58 | private readonly Dictionary<string, DatabaseProjectNode> m_DatabaseProjects = new Dictionary<string, DatabaseProjectNode>(); |
||
59 | private readonly List<ProjectNode> m_ProjectsOrder = new List<ProjectNode>(); |
||
60 | private readonly Dictionary<string, SolutionNode> m_Solutions = new Dictionary<string, SolutionNode>(); |
||
61 | private CleanupNode m_Cleanup; |
||
62 | |||
63 | #endregion |
||
64 | |||
65 | #region Properties |
||
66 | public override IDataNode Parent |
||
67 | { |
||
68 | get |
||
69 | { |
||
70 | return base.Parent; |
||
71 | } |
||
72 | set |
||
73 | { |
||
74 | if (value is SolutionNode) |
||
75 | { |
||
76 | SolutionNode solution = (SolutionNode)value; |
||
77 | foreach (ConfigurationNode conf in solution.Configurations) |
||
78 | { |
||
79 | m_Configurations[conf.Name] = (ConfigurationNode) conf.Clone(); |
||
80 | } |
||
81 | } |
||
82 | |||
83 | base.Parent = value; |
||
84 | } |
||
85 | } |
||
86 | |||
87 | public CleanupNode Cleanup |
||
88 | { |
||
89 | get |
||
90 | { |
||
91 | return m_Cleanup; |
||
92 | } |
||
93 | set |
||
94 | { |
||
95 | m_Cleanup = value; |
||
96 | } |
||
97 | } |
||
98 | |||
99 | public Guid Guid |
||
100 | { |
||
101 | get |
||
102 | { |
||
103 | return m_Guid; |
||
104 | } |
||
105 | set |
||
106 | { |
||
107 | m_Guid = value; |
||
108 | } |
||
109 | } |
||
110 | /// <summary> |
||
111 | /// Gets or sets the active config. |
||
112 | /// </summary> |
||
113 | /// <value>The active config.</value> |
||
114 | public string ActiveConfig |
||
115 | { |
||
116 | get |
||
117 | { |
||
118 | return m_ActiveConfig; |
||
119 | } |
||
120 | set |
||
121 | { |
||
122 | m_ActiveConfig = value; |
||
123 | } |
||
124 | } |
||
125 | |||
126 | /// <summary> |
||
127 | /// Gets the name. |
||
128 | /// </summary> |
||
129 | /// <value>The name.</value> |
||
130 | public string Name |
||
131 | { |
||
132 | get |
||
133 | { |
||
134 | return m_Name; |
||
135 | } |
||
136 | } |
||
137 | |||
138 | /// <summary> |
||
139 | /// Gets the path. |
||
140 | /// </summary> |
||
141 | /// <value>The path.</value> |
||
142 | public string Path |
||
143 | { |
||
144 | get |
||
145 | { |
||
146 | return m_Path; |
||
147 | } |
||
148 | } |
||
149 | |||
150 | /// <summary> |
||
151 | /// Gets the full path. |
||
152 | /// </summary> |
||
153 | /// <value>The full path.</value> |
||
154 | public string FullPath |
||
155 | { |
||
156 | get |
||
157 | { |
||
158 | return m_FullPath; |
||
159 | } |
||
160 | } |
||
161 | |||
162 | /// <summary> |
||
163 | /// Gets the version. |
||
164 | /// </summary> |
||
165 | /// <value>The version.</value> |
||
166 | public string Version |
||
167 | { |
||
168 | get |
||
169 | { |
||
170 | return m_Version; |
||
171 | } |
||
172 | } |
||
173 | |||
174 | /// <summary> |
||
175 | /// Gets the options. |
||
176 | /// </summary> |
||
177 | /// <value>The options.</value> |
||
178 | public OptionsNode Options |
||
179 | { |
||
180 | get |
||
181 | { |
||
182 | return m_Options; |
||
183 | } |
||
184 | } |
||
185 | |||
186 | /// <summary> |
||
187 | /// Gets the files. |
||
188 | /// </summary> |
||
189 | /// <value>The files.</value> |
||
190 | public FilesNode Files |
||
191 | { |
||
192 | get |
||
193 | { |
||
194 | return m_Files; |
||
195 | } |
||
196 | } |
||
197 | |||
198 | /// <summary> |
||
199 | /// Gets the configurations. |
||
200 | /// </summary> |
||
201 | /// <value>The configurations.</value> |
||
202 | public ConfigurationNodeCollection Configurations |
||
203 | { |
||
204 | get |
||
205 | { |
||
206 | ConfigurationNodeCollection tmp = new ConfigurationNodeCollection(); |
||
207 | tmp.AddRange(ConfigurationsTable); |
||
208 | return tmp; |
||
209 | } |
||
210 | } |
||
211 | |||
212 | /// <summary> |
||
213 | /// Gets the configurations table. |
||
214 | /// </summary> |
||
215 | /// <value>The configurations table.</value> |
||
216 | public ConfigurationNodeCollection ConfigurationsTable |
||
217 | { |
||
218 | get |
||
219 | { |
||
220 | return m_Configurations; |
||
221 | } |
||
222 | } |
||
223 | /// <summary> |
||
224 | /// Gets the database projects. |
||
225 | /// </summary> |
||
226 | public ICollection<DatabaseProjectNode> DatabaseProjects |
||
227 | { |
||
228 | get |
||
229 | { |
||
230 | return m_DatabaseProjects.Values; |
||
231 | } |
||
232 | } |
||
233 | /// <summary> |
||
234 | /// Gets the nested solutions. |
||
235 | /// </summary> |
||
236 | public ICollection<SolutionNode> Solutions |
||
237 | { |
||
238 | get |
||
239 | { |
||
240 | return m_Solutions.Values; |
||
241 | } |
||
242 | } |
||
243 | /// <summary> |
||
244 | /// Gets the nested solutions hash table. |
||
245 | /// </summary> |
||
246 | public Dictionary<string, SolutionNode> SolutionsTable |
||
247 | { |
||
248 | get |
||
249 | { |
||
250 | return m_Solutions; |
||
251 | } |
||
252 | } |
||
253 | /// <summary> |
||
254 | /// Gets the projects. |
||
255 | /// </summary> |
||
256 | /// <value>The projects.</value> |
||
257 | public ICollection<ProjectNode> Projects |
||
258 | { |
||
259 | get |
||
260 | { |
||
261 | List<ProjectNode> tmp = new List<ProjectNode>(m_Projects.Values); |
||
262 | tmp.Sort(); |
||
263 | return tmp; |
||
264 | } |
||
265 | } |
||
266 | |||
267 | /// <summary> |
||
268 | /// Gets the projects table. |
||
269 | /// </summary> |
||
270 | /// <value>The projects table.</value> |
||
271 | public Dictionary<string, ProjectNode> ProjectsTable |
||
272 | { |
||
273 | get |
||
274 | { |
||
275 | return m_Projects; |
||
276 | } |
||
277 | } |
||
278 | |||
279 | /// <summary> |
||
280 | /// Gets the projects table. |
||
281 | /// </summary> |
||
282 | /// <value>The projects table.</value> |
||
283 | public List<ProjectNode> ProjectsTableOrder |
||
284 | { |
||
285 | get |
||
286 | { |
||
287 | return m_ProjectsOrder; |
||
288 | } |
||
289 | } |
||
290 | |||
291 | #endregion |
||
292 | |||
293 | #region Public Methods |
||
294 | |||
295 | /// <summary> |
||
296 | /// Parses the specified node. |
||
297 | /// </summary> |
||
298 | /// <param name="node">The node.</param> |
||
299 | public override void Parse(XmlNode node) |
||
300 | { |
||
301 | m_Name = Helper.AttributeValue(node, "name", m_Name); |
||
302 | m_ActiveConfig = Helper.AttributeValue(node, "activeConfig", m_ActiveConfig); |
||
303 | m_Path = Helper.AttributeValue(node, "path", m_Path); |
||
304 | m_Version = Helper.AttributeValue(node, "version", m_Version); |
||
305 | |||
306 | m_FullPath = m_Path; |
||
307 | try |
||
308 | { |
||
309 | m_FullPath = Helper.ResolvePath(m_FullPath); |
||
310 | } |
||
311 | catch |
||
312 | { |
||
313 | throw new WarningException("Could not resolve solution path: {0}", m_Path); |
||
314 | } |
||
315 | |||
316 | Kernel.Instance.CurrentWorkingDirectory.Push(); |
||
317 | try |
||
318 | { |
||
319 | Helper.SetCurrentDir(m_FullPath); |
||
320 | |||
321 | if( node == null ) |
||
322 | { |
||
323 | throw new ArgumentNullException("node"); |
||
324 | } |
||
325 | |||
326 | foreach(XmlNode child in node.ChildNodes) |
||
327 | { |
||
328 | IDataNode dataNode = Kernel.Instance.ParseNode(child, this); |
||
329 | if(dataNode is OptionsNode) |
||
330 | { |
||
331 | m_Options = (OptionsNode)dataNode; |
||
332 | } |
||
333 | else if(dataNode is FilesNode) |
||
334 | { |
||
335 | m_Files = (FilesNode)dataNode; |
||
336 | } |
||
337 | else if(dataNode is ConfigurationNode) |
||
338 | { |
||
339 | ConfigurationNode configurationNode = (ConfigurationNode) dataNode; |
||
340 | m_Configurations[configurationNode.NameAndPlatform] = configurationNode; |
||
341 | |||
342 | // If the active configuration is null, then we populate it. |
||
343 | if (ActiveConfig == null) |
||
344 | { |
||
345 | ActiveConfig = configurationNode.Name; |
||
346 | } |
||
347 | } |
||
348 | else if(dataNode is ProjectNode) |
||
349 | { |
||
350 | m_Projects[((ProjectNode)dataNode).Name] = (ProjectNode) dataNode; |
||
351 | m_ProjectsOrder.Add((ProjectNode)dataNode); |
||
352 | } |
||
353 | else if(dataNode is SolutionNode) |
||
354 | { |
||
355 | m_Solutions[((SolutionNode)dataNode).Name] = (SolutionNode) dataNode; |
||
356 | } |
||
357 | else if (dataNode is ProcessNode) |
||
358 | { |
||
359 | ProcessNode p = (ProcessNode)dataNode; |
||
360 | Kernel.Instance.ProcessFile(p, this); |
||
361 | } |
||
362 | else if (dataNode is DatabaseProjectNode) |
||
363 | { |
||
364 | m_DatabaseProjects[((DatabaseProjectNode)dataNode).Name] = (DatabaseProjectNode) dataNode; |
||
365 | } |
||
366 | else if(dataNode is CleanupNode) |
||
367 | { |
||
368 | if(m_Cleanup != null) |
||
369 | throw new WarningException("There can only be one Cleanup node."); |
||
370 | m_Cleanup = (CleanupNode)dataNode; |
||
371 | } |
||
372 | } |
||
373 | } |
||
374 | finally |
||
375 | { |
||
376 | Kernel.Instance.CurrentWorkingDirectory.Pop(); |
||
377 | } |
||
378 | } |
||
379 | |||
380 | #endregion |
||
381 | } |
||
382 | } |