aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Prebuild/src/Core/Nodes/ConfigurationNode.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Prebuild/src/Core/Nodes/ConfigurationNode.cs')
-rw-r--r--Prebuild/src/Core/Nodes/ConfigurationNode.cs177
1 files changed, 177 insertions, 0 deletions
diff --git a/Prebuild/src/Core/Nodes/ConfigurationNode.cs b/Prebuild/src/Core/Nodes/ConfigurationNode.cs
new file mode 100644
index 0000000..e1488a7
--- /dev/null
+++ b/Prebuild/src/Core/Nodes/ConfigurationNode.cs
@@ -0,0 +1,177 @@
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-01-28 01:49:58 +0100 (lö, 28 jan 2006) $
31 * $Revision: 71 $
32 */
33#endregion
34
35using System;
36using System.Xml;
37
38using Prebuild.Core.Attributes;
39using Prebuild.Core.Interfaces;
40using Prebuild.Core.Utilities;
41
42namespace Prebuild.Core.Nodes
43{
44 /// <summary>
45 ///
46 /// </summary>
47 [DataNode("Configuration")]
48 public class ConfigurationNode : DataNode, ICloneable
49 {
50 #region Fields
51
52 private string m_Name = "unknown";
53 private OptionsNode m_Options;
54
55 #endregion
56
57 #region Constructors
58
59 /// <summary>
60 /// Initializes a new instance of the <see cref="ConfigurationNode"/> class.
61 /// </summary>
62 public ConfigurationNode()
63 {
64 m_Options = new OptionsNode();
65 }
66
67 #endregion
68
69 #region Properties
70
71 /// <summary>
72 /// Gets or sets the parent.
73 /// </summary>
74 /// <value>The parent.</value>
75 public override IDataNode Parent
76 {
77 get
78 {
79 return base.Parent;
80 }
81 set
82 {
83 base.Parent = value;
84 if(base.Parent is SolutionNode)
85 {
86 SolutionNode node = (SolutionNode)base.Parent;
87 if(node != null && node.Options != null)
88 {
89 node.Options.CopyTo(m_Options);
90 }
91 }
92 }
93 }
94
95 /// <summary>
96 /// Gets the name.
97 /// </summary>
98 /// <value>The name.</value>
99 public string Name
100 {
101 get
102 {
103 return m_Name;
104 }
105 }
106
107 /// <summary>
108 /// Gets or sets the options.
109 /// </summary>
110 /// <value>The options.</value>
111 public OptionsNode Options
112 {
113 get
114 {
115 return m_Options;
116 }
117 set
118 {
119 m_Options = value;
120 }
121 }
122
123 #endregion
124
125 #region Public Methods
126
127 /// <summary>
128 /// Parses the specified node.
129 /// </summary>
130 /// <param name="node">The node.</param>
131 public override void Parse(XmlNode node)
132 {
133 m_Name = Helper.AttributeValue(node, "name", m_Name);
134 if( node == null )
135 {
136 throw new ArgumentNullException("node");
137 }
138 foreach(XmlNode child in node.ChildNodes)
139 {
140 IDataNode dataNode = Kernel.Instance.ParseNode(child, this);
141 if(dataNode is OptionsNode)
142 {
143 ((OptionsNode)dataNode).CopyTo(m_Options);
144 }
145 }
146 }
147
148 /// <summary>
149 /// Copies to.
150 /// </summary>
151 /// <param name="conf">The conf.</param>
152 public void CopyTo(ConfigurationNode conf)
153 {
154 m_Options.CopyTo(conf.m_Options);
155 }
156
157 #endregion
158
159 #region ICloneable Members
160
161 /// <summary>
162 /// Creates a new object that is a copy of the current instance.
163 /// </summary>
164 /// <returns>
165 /// A new object that is a copy of this instance.
166 /// </returns>
167 public object Clone()
168 {
169 ConfigurationNode ret = new ConfigurationNode();
170 ret.m_Name = m_Name;
171 m_Options.CopyTo(ret.m_Options);
172 return ret;
173 }
174
175 #endregion
176 }
177}