aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Prebuild/src/Core/Nodes/ProjectNode.cs
diff options
context:
space:
mode:
authorMW2007-06-27 15:28:52 +0000
committerMW2007-06-27 15:28:52 +0000
commit646bbbc84b8010e0dacbeed5342cdb045f46cc49 (patch)
tree770b34d19855363c3c113ab9a0af9a56d821d887 /Prebuild/src/Core/Nodes/ProjectNode.cs
downloadopensim-SC_OLD-646bbbc84b8010e0dacbeed5342cdb045f46cc49.zip
opensim-SC_OLD-646bbbc84b8010e0dacbeed5342cdb045f46cc49.tar.gz
opensim-SC_OLD-646bbbc84b8010e0dacbeed5342cdb045f46cc49.tar.bz2
opensim-SC_OLD-646bbbc84b8010e0dacbeed5342cdb045f46cc49.tar.xz
Some work on restructuring the namespaces / project names. Note this doesn't compile yet as not all the code has been changed to use the new namespaces. Am committing it now for feedback on the namespaces.
Diffstat (limited to 'Prebuild/src/Core/Nodes/ProjectNode.cs')
-rw-r--r--Prebuild/src/Core/Nodes/ProjectNode.cs510
1 files changed, 510 insertions, 0 deletions
diff --git a/Prebuild/src/Core/Nodes/ProjectNode.cs b/Prebuild/src/Core/Nodes/ProjectNode.cs
new file mode 100644
index 0000000..c56dacc
--- /dev/null
+++ b/Prebuild/src/Core/Nodes/ProjectNode.cs
@@ -0,0 +1,510 @@
1#region BSD License
2/*
3Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com)
4
5Redistribution and use in source and binary forms, with or without modification, are permitted
6provided 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
16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
17BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
22IN 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: jendave $
30 * $Date: 2006-11-11 05:43:20 +0100 (lö, 11 nov 2006) $
31 * $Revision: 192 $
32 */
33#endregion
34
35using System;
36using System.Collections;
37using System.IO;
38using System.Xml;
39
40using Prebuild.Core.Attributes;
41using Prebuild.Core.Interfaces;
42using Prebuild.Core.Utilities;
43
44namespace Prebuild.Core.Nodes
45{
46 /// <summary>
47 ///
48 /// </summary>
49 public enum ProjectType
50 {
51 /// <summary>
52 ///
53 /// </summary>
54 Exe,
55 /// <summary>
56 ///
57 /// </summary>
58 WinExe,
59 /// <summary>
60 ///
61 /// </summary>
62 Library
63 }
64
65 /// <summary>
66 ///
67 /// </summary>
68 public enum ClrRuntime
69 {
70 /// <summary>
71 ///
72 /// </summary>
73 Microsoft,
74 /// <summary>
75 ///
76 /// </summary>
77 Mono
78 }
79
80 /// <summary>
81 ///
82 /// </summary>
83 [DataNode("Project")]
84 public class ProjectNode : DataNode, IComparable
85 {
86 #region Fields
87
88 private string m_Name = "unknown";
89 private string m_Path = "";
90 private string m_FullPath = "";
91 private string m_AssemblyName;
92 private string m_AppIcon = "";
93 private string m_DesignerFolder = "";
94 private string m_Language = "C#";
95 private ProjectType m_Type = ProjectType.Exe;
96 private ClrRuntime m_Runtime = ClrRuntime.Microsoft;
97 private string m_StartupObject = "";
98 private string m_RootNamespace;
99 private string m_FilterGroups = "";
100 private Guid m_Guid;
101
102 private Hashtable m_Configurations;
103 private ArrayList m_ReferencePaths;
104 private ArrayList m_References;
105 private FilesNode m_Files;
106
107 #endregion
108
109 #region Constructors
110
111 /// <summary>
112 /// Initializes a new instance of the <see cref="ProjectNode"/> class.
113 /// </summary>
114 public ProjectNode()
115 {
116 m_Configurations = new Hashtable();
117 m_ReferencePaths = new ArrayList();
118 m_References = new ArrayList();
119 }
120
121 #endregion
122
123 #region Properties
124
125 /// <summary>
126 /// Gets the name.
127 /// </summary>
128 /// <value>The name.</value>
129 public string Name
130 {
131 get
132 {
133 return m_Name;
134 }
135 }
136
137 /// <summary>
138 /// Gets the path.
139 /// </summary>
140 /// <value>The path.</value>
141 public string Path
142 {
143 get
144 {
145 return m_Path;
146 }
147 }
148
149 /// <summary>
150 /// Gets the filter groups.
151 /// </summary>
152 /// <value>The filter groups.</value>
153 public string FilterGroups
154 {
155 get
156 {
157 return m_FilterGroups;
158 }
159 }
160
161 /// <summary>
162 /// Gets the full path.
163 /// </summary>
164 /// <value>The full path.</value>
165 public string FullPath
166 {
167 get
168 {
169 return m_FullPath;
170 }
171 }
172
173 /// <summary>
174 /// Gets the name of the assembly.
175 /// </summary>
176 /// <value>The name of the assembly.</value>
177 public string AssemblyName
178 {
179 get
180 {
181 return m_AssemblyName;
182 }
183 }
184
185 /// <summary>
186 /// Gets the app icon.
187 /// </summary>
188 /// <value>The app icon.</value>
189 public string AppIcon
190 {
191 get
192 {
193 return m_AppIcon;
194 }
195 }
196
197 /// <summary>
198 ///
199 /// </summary>
200 public string DesignerFolder
201 {
202 get
203 {
204 return m_DesignerFolder;
205 }
206 }
207
208 /// <summary>
209 /// Gets the language.
210 /// </summary>
211 /// <value>The language.</value>
212 public string Language
213 {
214 get
215 {
216 return m_Language;
217 }
218 }
219
220 /// <summary>
221 /// Gets the type.
222 /// </summary>
223 /// <value>The type.</value>
224 public ProjectType Type
225 {
226 get
227 {
228 return m_Type;
229 }
230 }
231
232 /// <summary>
233 /// Gets the runtime.
234 /// </summary>
235 /// <value>The runtime.</value>
236 public ClrRuntime Runtime
237 {
238 get
239 {
240 return m_Runtime;
241 }
242 }
243
244 private bool m_GenerateAssemblyInfoFile = false;
245
246 /// <summary>
247 ///
248 /// </summary>
249 public bool GenerateAssemblyInfoFile
250 {
251 get
252 {
253 return m_GenerateAssemblyInfoFile;
254 }
255 set
256 {
257 m_GenerateAssemblyInfoFile = value;
258 }
259 }
260
261 /// <summary>
262 /// Gets the startup object.
263 /// </summary>
264 /// <value>The startup object.</value>
265 public string StartupObject
266 {
267 get
268 {
269 return m_StartupObject;
270 }
271 }
272
273 /// <summary>
274 /// Gets the root namespace.
275 /// </summary>
276 /// <value>The root namespace.</value>
277 public string RootNamespace
278 {
279 get
280 {
281 return m_RootNamespace;
282 }
283 }
284
285 /// <summary>
286 /// Gets the configurations.
287 /// </summary>
288 /// <value>The configurations.</value>
289 public ICollection Configurations
290 {
291 get
292 {
293 ArrayList tmp = new ArrayList( ConfigurationsTable.Values);
294 tmp.Sort();
295 return tmp;
296 }
297 }
298
299 /// <summary>
300 /// Gets the configurations table.
301 /// </summary>
302 /// <value>The configurations table.</value>
303 public Hashtable ConfigurationsTable
304 {
305 get
306 {
307 return m_Configurations;
308 }
309 }
310
311 /// <summary>
312 /// Gets the reference paths.
313 /// </summary>
314 /// <value>The reference paths.</value>
315 public ArrayList ReferencePaths
316 {
317 get
318 {
319 ArrayList tmp = new ArrayList(m_ReferencePaths);
320 tmp.Sort();
321 return tmp;
322 }
323 }
324
325 /// <summary>
326 /// Gets the references.
327 /// </summary>
328 /// <value>The references.</value>
329 public ArrayList References
330 {
331 get
332 {
333 ArrayList tmp = new ArrayList(m_References);
334 tmp.Sort();
335 return tmp;
336 }
337 }
338
339 /// <summary>
340 /// Gets the files.
341 /// </summary>
342 /// <value>The files.</value>
343 public FilesNode Files
344 {
345 get
346 {
347 return m_Files;
348 }
349 }
350
351 /// <summary>
352 /// Gets or sets the parent.
353 /// </summary>
354 /// <value>The parent.</value>
355 public override IDataNode Parent
356 {
357 get
358 {
359 return base.Parent;
360 }
361 set
362 {
363 base.Parent = value;
364 if(base.Parent is SolutionNode && m_Configurations.Count < 1)
365 {
366 SolutionNode parent = (SolutionNode)base.Parent;
367 foreach(ConfigurationNode conf in parent.Configurations)
368 {
369 m_Configurations[conf.Name] = conf.Clone();
370 }
371 }
372 }
373 }
374
375 /// <summary>
376 /// Gets the GUID.
377 /// </summary>
378 /// <value>The GUID.</value>
379 public Guid Guid
380 {
381 get
382 {
383 return m_Guid;
384 }
385 }
386
387 #endregion
388
389 #region Private Methods
390
391 private void HandleConfiguration(ConfigurationNode conf)
392 {
393 if(String.Compare(conf.Name, "all", true) == 0) //apply changes to all, this may not always be applied first,
394 //so it *may* override changes to the same properties for configurations defines at the project level
395 {
396 foreach(ConfigurationNode confNode in this.m_Configurations.Values)
397 {
398 conf.CopyTo(confNode);//update the config templates defines at the project level with the overrides
399 }
400 }
401 if(m_Configurations.ContainsKey(conf.Name))
402 {
403 ConfigurationNode parentConf = (ConfigurationNode)m_Configurations[conf.Name];
404 conf.CopyTo(parentConf);//update the config templates defines at the project level with the overrides
405 }
406 else
407 {
408 m_Configurations[conf.Name] = conf;
409 }
410 }
411
412 #endregion
413
414 #region Public Methods
415
416 /// <summary>
417 /// Parses the specified node.
418 /// </summary>
419 /// <param name="node">The node.</param>
420 public override void Parse(XmlNode node)
421 {
422 m_Name = Helper.AttributeValue(node, "name", m_Name);
423 m_Path = Helper.AttributeValue(node, "path", m_Path);
424 m_FilterGroups = Helper.AttributeValue(node, "filterGroups", m_FilterGroups);
425 m_AppIcon = Helper.AttributeValue(node, "icon", m_AppIcon);
426 m_DesignerFolder = Helper.AttributeValue(node, "designerFolder", m_DesignerFolder);
427 m_AssemblyName = Helper.AttributeValue(node, "assemblyName", m_AssemblyName);
428 m_Language = Helper.AttributeValue(node, "language", m_Language);
429 m_Type = (ProjectType)Helper.EnumAttributeValue(node, "type", typeof(ProjectType), m_Type);
430 m_Runtime = (ClrRuntime)Helper.EnumAttributeValue(node, "runtime", typeof(ClrRuntime), m_Runtime);
431 m_StartupObject = Helper.AttributeValue(node, "startupObject", m_StartupObject);
432 m_RootNamespace = Helper.AttributeValue(node, "rootNamespace", m_RootNamespace);
433
434 int hash = m_Name.GetHashCode();
435
436 m_Guid = new Guid( hash, 0, 0, 0, 0, 0, 0,0,0,0,0 );
437
438 m_GenerateAssemblyInfoFile = Helper.ParseBoolean(node, "generateAssemblyInfoFile", false);
439
440 if(m_AssemblyName == null || m_AssemblyName.Length < 1)
441 {
442 m_AssemblyName = m_Name;
443 }
444
445 if(m_RootNamespace == null || m_RootNamespace.Length < 1)
446 {
447 m_RootNamespace = m_Name;
448 }
449
450 m_FullPath = m_Path;
451 try
452 {
453 m_FullPath = Helper.ResolvePath(m_FullPath);
454 }
455 catch
456 {
457 throw new WarningException("Could not resolve Solution path: {0}", m_Path);
458 }
459
460 Kernel.Instance.CurrentWorkingDirectory.Push();
461 try
462 {
463 Helper.SetCurrentDir(m_FullPath);
464
465 if( node == null )
466 {
467 throw new ArgumentNullException("node");
468 }
469
470 foreach(XmlNode child in node.ChildNodes)
471 {
472 IDataNode dataNode = Kernel.Instance.ParseNode(child, this);
473 if(dataNode is ConfigurationNode)
474 {
475 HandleConfiguration((ConfigurationNode)dataNode);
476 }
477 else if(dataNode is ReferencePathNode)
478 {
479 m_ReferencePaths.Add(dataNode);
480 }
481 else if(dataNode is ReferenceNode)
482 {
483 m_References.Add(dataNode);
484 }
485 else if(dataNode is FilesNode)
486 {
487 m_Files = (FilesNode)dataNode;
488 }
489 }
490 }
491 finally
492 {
493 Kernel.Instance.CurrentWorkingDirectory.Pop();
494 }
495 }
496
497
498 #endregion
499
500 #region IComparable Members
501
502 public int CompareTo(object obj)
503 {
504 ProjectNode that = (ProjectNode)obj;
505 return this.m_Name.CompareTo(that.m_Name);
506 }
507
508 #endregion
509 }
510}