aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Prebuild/src/Core/Nodes/SolutionNode.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Prebuild/src/Core/Nodes/SolutionNode.cs')
-rw-r--r--Prebuild/src/Core/Nodes/SolutionNode.cs288
1 files changed, 288 insertions, 0 deletions
diff --git a/Prebuild/src/Core/Nodes/SolutionNode.cs b/Prebuild/src/Core/Nodes/SolutionNode.cs
new file mode 100644
index 0000000..c777fa4
--- /dev/null
+++ b/Prebuild/src/Core/Nodes/SolutionNode.cs
@@ -0,0 +1,288 @@
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-02-28 17:15:42 +0100 (ti, 28 feb 2006) $
31 * $Revision: 92 $
32 */
33#endregion
34
35using System;
36using System.Collections;
37using System.Diagnostics;
38using System.IO;
39using System.Xml;
40
41using Prebuild.Core.Attributes;
42using Prebuild.Core.Interfaces;
43using Prebuild.Core.Utilities;
44
45namespace Prebuild.Core.Nodes
46{
47 /// <summary>
48 ///
49 /// </summary>
50 [DataNode("Solution")]
51 public class SolutionNode : DataNode
52 {
53 #region Fields
54
55 private string m_Name = "unknown";
56 private string m_Path = "";
57 private string m_FullPath = "";
58 private string m_ActiveConfig = "Debug";
59
60 private OptionsNode m_Options;
61 private FilesNode m_Files;
62 private Hashtable m_Configurations;
63 private Hashtable m_Projects;
64 private ArrayList m_ProjectsOrder;
65
66 #endregion
67
68 #region Constructors
69
70 /// <summary>
71 /// Initializes a new instance of the <see cref="SolutionNode"/> class.
72 /// </summary>
73 public SolutionNode()
74 {
75 m_Configurations = new Hashtable();
76 m_Projects = new Hashtable();
77 m_ProjectsOrder = new ArrayList();
78 }
79
80 #endregion
81
82 #region Properties
83
84 /// <summary>
85 /// Gets or sets the active config.
86 /// </summary>
87 /// <value>The active config.</value>
88 public string ActiveConfig
89 {
90 get
91 {
92 return m_ActiveConfig;
93 }
94 set
95 {
96 m_ActiveConfig = value;
97 }
98 }
99
100 /// <summary>
101 /// Gets the name.
102 /// </summary>
103 /// <value>The name.</value>
104 public string Name
105 {
106 get
107 {
108 return m_Name;
109 }
110 }
111
112 /// <summary>
113 /// Gets the path.
114 /// </summary>
115 /// <value>The path.</value>
116 public string Path
117 {
118 get
119 {
120 return m_Path;
121 }
122 }
123
124 /// <summary>
125 /// Gets the full path.
126 /// </summary>
127 /// <value>The full path.</value>
128 public string FullPath
129 {
130 get
131 {
132 return m_FullPath;
133 }
134 }
135
136 /// <summary>
137 /// Gets the options.
138 /// </summary>
139 /// <value>The options.</value>
140 public OptionsNode Options
141 {
142 get
143 {
144 return m_Options;
145 }
146 }
147
148 /// <summary>
149 /// Gets the files.
150 /// </summary>
151 /// <value>The files.</value>
152 public FilesNode Files
153 {
154 get
155 {
156 return m_Files;
157 }
158 }
159
160 /// <summary>
161 /// Gets the configurations.
162 /// </summary>
163 /// <value>The configurations.</value>
164 public ICollection Configurations
165 {
166 get
167 {
168 ArrayList tmp = new ArrayList(ConfigurationsTable.Values);
169 tmp.Sort();
170 return tmp;
171 }
172 }
173
174 /// <summary>
175 /// Gets the configurations table.
176 /// </summary>
177 /// <value>The configurations table.</value>
178 public Hashtable ConfigurationsTable
179 {
180 get
181 {
182 return m_Configurations;
183 }
184 }
185
186 /// <summary>
187 /// Gets the projects.
188 /// </summary>
189 /// <value>The projects.</value>
190 public ICollection Projects
191 {
192 get
193 {
194 ArrayList tmp = new ArrayList(m_Projects.Values);
195 tmp.Sort();
196 return tmp;
197 }
198 }
199
200 /// <summary>
201 /// Gets the projects table.
202 /// </summary>
203 /// <value>The projects table.</value>
204 public Hashtable ProjectsTable
205 {
206 get
207 {
208 return m_Projects;
209 }
210 }
211
212 /// <summary>
213 /// Gets the projects table.
214 /// </summary>
215 /// <value>The projects table.</value>
216 public ArrayList ProjectsTableOrder
217 {
218 get
219 {
220 return m_ProjectsOrder;
221 }
222 }
223
224 #endregion
225
226 #region Public Methods
227
228 /// <summary>
229 /// Parses the specified node.
230 /// </summary>
231 /// <param name="node">The node.</param>
232 public override void Parse(XmlNode node)
233 {
234 m_Name = Helper.AttributeValue(node, "name", m_Name);
235 m_ActiveConfig = Helper.AttributeValue(node, "activeConfig", m_ActiveConfig);
236 m_Path = Helper.AttributeValue(node, "path", m_Path);
237
238 m_FullPath = m_Path;
239 try
240 {
241 m_FullPath = Helper.ResolvePath(m_FullPath);
242 }
243 catch
244 {
245 throw new WarningException("Could not resolve solution path: {0}", m_Path);
246 }
247
248 Kernel.Instance.CurrentWorkingDirectory.Push();
249 try
250 {
251 Helper.SetCurrentDir(m_FullPath);
252
253 if( node == null )
254 {
255 throw new ArgumentNullException("node");
256 }
257
258 foreach(XmlNode child in node.ChildNodes)
259 {
260 IDataNode dataNode = Kernel.Instance.ParseNode(child, this);
261 if(dataNode is OptionsNode)
262 {
263 m_Options = (OptionsNode)dataNode;
264 }
265 else if(dataNode is FilesNode)
266 {
267 m_Files = (FilesNode)dataNode;
268 }
269 else if(dataNode is ConfigurationNode)
270 {
271 m_Configurations[((ConfigurationNode)dataNode).Name] = dataNode;
272 }
273 else if(dataNode is ProjectNode)
274 {
275 m_Projects[((ProjectNode)dataNode).Name] = dataNode;
276 m_ProjectsOrder.Add(dataNode);
277 }
278 }
279 }
280 finally
281 {
282 Kernel.Instance.CurrentWorkingDirectory.Pop();
283 }
284 }
285
286 #endregion
287 }
288}