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.cs284
1 files changed, 284 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..0121075
--- /dev/null
+++ b/Prebuild/src/Core/Nodes/SolutionNode.cs
@@ -0,0 +1,284 @@
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 return m_Configurations.Values;
169 }
170 }
171
172 /// <summary>
173 /// Gets the configurations table.
174 /// </summary>
175 /// <value>The configurations table.</value>
176 public Hashtable ConfigurationsTable
177 {
178 get
179 {
180 return m_Configurations;
181 }
182 }
183
184 /// <summary>
185 /// Gets the projects.
186 /// </summary>
187 /// <value>The projects.</value>
188 public ICollection Projects
189 {
190 get
191 {
192 return m_Projects.Values;
193 }
194 }
195
196 /// <summary>
197 /// Gets the projects table.
198 /// </summary>
199 /// <value>The projects table.</value>
200 public Hashtable ProjectsTable
201 {
202 get
203 {
204 return m_Projects;
205 }
206 }
207
208 /// <summary>
209 /// Gets the projects table.
210 /// </summary>
211 /// <value>The projects table.</value>
212 public ArrayList ProjectsTableOrder
213 {
214 get
215 {
216 return m_ProjectsOrder;
217 }
218 }
219
220 #endregion
221
222 #region Public Methods
223
224 /// <summary>
225 /// Parses the specified node.
226 /// </summary>
227 /// <param name="node">The node.</param>
228 public override void Parse(XmlNode node)
229 {
230 m_Name = Helper.AttributeValue(node, "name", m_Name);
231 m_ActiveConfig = Helper.AttributeValue(node, "activeConfig", m_ActiveConfig);
232 m_Path = Helper.AttributeValue(node, "path", m_Path);
233
234 m_FullPath = m_Path;
235 try
236 {
237 m_FullPath = Helper.ResolvePath(m_FullPath);
238 }
239 catch
240 {
241 throw new WarningException("Could not resolve solution path: {0}", m_Path);
242 }
243
244 Kernel.Instance.CurrentWorkingDirectory.Push();
245 try
246 {
247 Helper.SetCurrentDir(m_FullPath);
248
249 if( node == null )
250 {
251 throw new ArgumentNullException("node");
252 }
253
254 foreach(XmlNode child in node.ChildNodes)
255 {
256 IDataNode dataNode = Kernel.Instance.ParseNode(child, this);
257 if(dataNode is OptionsNode)
258 {
259 m_Options = (OptionsNode)dataNode;
260 }
261 else if(dataNode is FilesNode)
262 {
263 m_Files = (FilesNode)dataNode;
264 }
265 else if(dataNode is ConfigurationNode)
266 {
267 m_Configurations[((ConfigurationNode)dataNode).Name] = dataNode;
268 }
269 else if(dataNode is ProjectNode)
270 {
271 m_Projects[((ProjectNode)dataNode).Name] = dataNode;
272 m_ProjectsOrder.Add(dataNode);
273 }
274 }
275 }
276 finally
277 {
278 Kernel.Instance.CurrentWorkingDirectory.Pop();
279 }
280 }
281
282 #endregion
283 }
284}