corrade-vassal – Blame information for rev 1

Subversion Repositories:
Rev:
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 #region CVS Information
27 /*
28 * $Source$
29 * $Author: sontek $
30 * $Date: 2008-04-30 16:36:53 -0700 (Wed, 30 Apr 2008) $
31 * $Revision: 267 $
32 */
33 #endregion
34  
35 using System;
36 using System.Collections;
37 using System.Diagnostics;
38 using System.IO;
39 using System.Xml;
40  
41 using Prebuild.Core.Attributes;
42 using Prebuild.Core.Interfaces;
43 using Prebuild.Core.Utilities;
44  
45 namespace Prebuild.Core.Nodes
46 {
47 /// <summary>
48 ///
49 /// </summary>
50 [DataNode("Solution")]
51 [DataNode("EmbeddedSolution")]
52 [DebuggerDisplay("{Name}")]
53 public class SolutionNode : DataNode
54 {
55 #region Fields
56  
57 private Guid m_Guid = Guid.NewGuid();
58 private string m_Name = "unknown";
59 private string m_Path = "";
60 private string m_FullPath = "";
61 private string m_ActiveConfig = "Debug";
62  
63 private OptionsNode m_Options;
64 private FilesNode m_Files;
65 private Hashtable m_Configurations;
66 private Hashtable m_Projects;
67 private Hashtable m_DatabaseProjects;
68 private ArrayList m_ProjectsOrder;
69 private Hashtable m_Solutions;
70  
71 #endregion
72  
73 #region Constructors
74  
75 /// <summary>
76 /// Initializes a new instance of the <see cref="SolutionNode"/> class.
77 /// </summary>
78 public SolutionNode()
79 {
80 m_Configurations = new Hashtable();
81 m_Projects = new Hashtable();
82 m_ProjectsOrder = new ArrayList();
83 m_DatabaseProjects = new Hashtable();
84 m_Solutions = new Hashtable();
85 }
86  
87 #endregion
88  
89 #region Properties
90 public override IDataNode Parent
91 {
92 get
93 {
94 return base.Parent;
95 }
96 set
97 {
98 if (value is SolutionNode)
99 {
100 SolutionNode solution = (SolutionNode)value;
101 foreach (ConfigurationNode conf in solution.Configurations)
102 {
103 m_Configurations[conf.Name] = conf.Clone();
104 }
105 }
106  
107 base.Parent = value;
108 }
109 }
110  
111 public Guid Guid
112 {
113 get
114 {
115 return m_Guid;
116 }
117 set
118 {
119 m_Guid = value;
120 }
121 }
122 /// <summary>
123 /// Gets or sets the active config.
124 /// </summary>
125 /// <value>The active config.</value>
126 public string ActiveConfig
127 {
128 get
129 {
130 return m_ActiveConfig;
131 }
132 set
133 {
134 m_ActiveConfig = value;
135 }
136 }
137  
138 /// <summary>
139 /// Gets the name.
140 /// </summary>
141 /// <value>The name.</value>
142 public string Name
143 {
144 get
145 {
146 return m_Name;
147 }
148 }
149  
150 /// <summary>
151 /// Gets the path.
152 /// </summary>
153 /// <value>The path.</value>
154 public string Path
155 {
156 get
157 {
158 return m_Path;
159 }
160 }
161  
162 /// <summary>
163 /// Gets the full path.
164 /// </summary>
165 /// <value>The full path.</value>
166 public string FullPath
167 {
168 get
169 {
170 return m_FullPath;
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 ICollection Configurations
203 {
204 get
205 {
206 return m_Configurations.Values;
207 }
208 }
209  
210 /// <summary>
211 /// Gets the configurations table.
212 /// </summary>
213 /// <value>The configurations table.</value>
214 public Hashtable ConfigurationsTable
215 {
216 get
217 {
218 return m_Configurations;
219 }
220 }
221 /// <summary>
222 /// Gets the database projects.
223 /// </summary>
224 public ICollection DatabaseProjects
225 {
226 get
227 {
228 return m_DatabaseProjects.Values;
229 }
230 }
231 /// <summary>
232 /// Gets the nested solutions.
233 /// </summary>
234 public ICollection Solutions
235 {
236 get
237 {
238 return m_Solutions.Values;
239 }
240 }
241 /// <summary>
242 /// Gets the nested solutions hash table.
243 /// </summary>
244 public Hashtable SolutionsTable
245 {
246 get
247 {
248 return this.m_Solutions;
249 }
250 }
251 /// <summary>
252 /// Gets the projects.
253 /// </summary>
254 /// <value>The projects.</value>
255 public ICollection Projects
256 {
257 get
258 {
259 return m_Projects.Values;
260 }
261 }
262  
263 /// <summary>
264 /// Gets the projects table.
265 /// </summary>
266 /// <value>The projects table.</value>
267 public Hashtable ProjectsTable
268 {
269 get
270 {
271 return m_Projects;
272 }
273 }
274  
275 /// <summary>
276 /// Gets the projects table.
277 /// </summary>
278 /// <value>The projects table.</value>
279 public ArrayList ProjectsTableOrder
280 {
281 get
282 {
283 return m_ProjectsOrder;
284 }
285 }
286  
287 #endregion
288  
289 #region Public Methods
290  
291 /// <summary>
292 /// Parses the specified node.
293 /// </summary>
294 /// <param name="node">The node.</param>
295 public override void Parse(XmlNode node)
296 {
297 m_Name = Helper.AttributeValue(node, "name", m_Name);
298 m_ActiveConfig = Helper.AttributeValue(node, "activeConfig", m_ActiveConfig);
299 m_Path = Helper.AttributeValue(node, "path", m_Path);
300  
301 m_FullPath = m_Path;
302 try
303 {
304 m_FullPath = Helper.ResolvePath(m_FullPath);
305 }
306 catch
307 {
308 throw new WarningException("Could not resolve solution path: {0}", m_Path);
309 }
310  
311 Kernel.Instance.CurrentWorkingDirectory.Push();
312 try
313 {
314 Helper.SetCurrentDir(m_FullPath);
315  
316 if( node == null )
317 {
318 throw new ArgumentNullException("node");
319 }
320  
321 foreach(XmlNode child in node.ChildNodes)
322 {
323 IDataNode dataNode = Kernel.Instance.ParseNode(child, this);
324 if(dataNode is OptionsNode)
325 {
326 m_Options = (OptionsNode)dataNode;
327 }
328 else if(dataNode is FilesNode)
329 {
330 m_Files = (FilesNode)dataNode;
331 }
332 else if(dataNode is ConfigurationNode)
333 {
334 m_Configurations[((ConfigurationNode)dataNode).Name] = dataNode;
335 }
336 else if(dataNode is ProjectNode)
337 {
338 m_Projects[((ProjectNode)dataNode).Name] = dataNode;
339 m_ProjectsOrder.Add(dataNode);
340 }
341 else if(dataNode is SolutionNode)
342 {
343 m_Solutions[((SolutionNode)dataNode).Name] = dataNode;
344 }
345 else if (dataNode is ProcessNode)
346 {
347 ProcessNode p = (ProcessNode)dataNode;
348 Kernel.Instance.ProcessFile(p, this);
349 }
350 else if (dataNode is DatabaseProjectNode)
351 {
352 m_DatabaseProjects[((DatabaseProjectNode)dataNode).Name] = dataNode;
353 }
354 }
355 }
356 finally
357 {
358 Kernel.Instance.CurrentWorkingDirectory.Pop();
359 }
360 }
361  
362 #endregion
363 }
364 }