clockwerk-opensim – 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 using System;
27 using System.Xml;
28  
29 using Prebuild.Core.Attributes;
30 using Prebuild.Core.Interfaces;
31 using Prebuild.Core.Utilities;
32  
33 namespace Prebuild.Core.Nodes
34 {
35 /// <summary>
36 ///
37 /// </summary>
38 [DataNode("Configuration")]
39 public class ConfigurationNode : DataNode, ICloneable, IComparable
40 {
41 #region Fields
42  
43 private string m_Name = "unknown";
44 private string m_Platform = "AnyCPU";
45 private OptionsNode m_Options;
46  
47 #endregion
48  
49 #region Constructors
50  
51 /// <summary>
52 /// Initializes a new instance of the <see cref="ConfigurationNode"/> class.
53 /// </summary>
54 public ConfigurationNode()
55 {
56 m_Options = new OptionsNode();
57 }
58  
59 #endregion
60  
61 #region Properties
62  
63 /// <summary>
64 /// Gets or sets the parent.
65 /// </summary>
66 /// <value>The parent.</value>
67 public override IDataNode Parent
68 {
69 get
70 {
71 return base.Parent;
72 }
73 set
74 {
75 base.Parent = value;
76 if(base.Parent is SolutionNode)
77 {
78 SolutionNode node = (SolutionNode)base.Parent;
79 if(node != null && node.Options != null)
80 {
81 node.Options.CopyTo(m_Options);
82 }
83 }
84 }
85 }
86  
87 /// <summary>
88 /// Identifies the platform for this specific configuration.
89 /// </summary>
90 public string Platform
91 {
92 get
93 {
94 return m_Platform;
95 }
96 set
97 {
98 switch ((value + "").ToLower())
99 {
100 case "x86":
101 case "x64":
102 m_Platform = value;
103 break;
104 case "itanium":
105 m_Platform = "Itanium";
106 break;
107 default:
108 m_Platform = "AnyCPU";
109 break;
110 }
111 }
112 }
113  
114 /// <summary>
115 /// Gets the name.
116 /// </summary>
117 /// <value>The name.</value>
118 public string Name
119 {
120 get
121 {
122 return m_Name;
123 }
124 }
125  
126 /// <summary>
127 /// Gets the name and platform for the configuration.
128 /// </summary>
129 /// <value>The name and platform.</value>
130 public string NameAndPlatform
131 {
132 get
133 {
134 string platform = m_Platform;
135 if (platform == "AnyCPU")
136 platform = "Any CPU";
137  
138 return String.Format("{0}|{1}", m_Name, platform);
139 }
140 }
141  
142 /// <summary>
143 /// Gets or sets the options.
144 /// </summary>
145 /// <value>The options.</value>
146 public OptionsNode Options
147 {
148 get
149 {
150 return m_Options;
151 }
152 set
153 {
154 m_Options = value;
155 }
156 }
157  
158 #endregion
159  
160 #region Public Methods
161  
162 /// <summary>
163 /// Parses the specified node.
164 /// </summary>
165 /// <param name="node">The node.</param>
166 public override void Parse(XmlNode node)
167 {
168 m_Name = Helper.AttributeValue(node, "name", m_Name);
169 Platform = Helper.AttributeValue(node, "platform", m_Platform);
170  
171 if (node == null)
172 {
173 throw new ArgumentNullException("node");
174 }
175 foreach(XmlNode child in node.ChildNodes)
176 {
177 IDataNode dataNode = Kernel.Instance.ParseNode(child, this);
178 if(dataNode is OptionsNode)
179 {
180 ((OptionsNode)dataNode).CopyTo(m_Options);
181 }
182 }
183 }
184  
185 /// <summary>
186 /// Copies to.
187 /// </summary>
188 /// <param name="conf">The conf.</param>
189 public void CopyTo(ConfigurationNode conf)
190 {
191 m_Options.CopyTo(conf.m_Options);
192 }
193  
194 #endregion
195  
196 #region ICloneable Members
197  
198 /// <summary>
199 /// Creates a new object that is a copy of the current instance.
200 /// </summary>
201 /// <returns>
202 /// A new object that is a copy of this instance.
203 /// </returns>
204 public object Clone()
205 {
206 ConfigurationNode ret = new ConfigurationNode();
207 ret.m_Name = m_Name;
208 ret.m_Platform = m_Platform;
209 m_Options.CopyTo(ret.m_Options);
210 return ret;
211 }
212  
213 #endregion
214  
215 #region IComparable Members
216  
217 public int CompareTo(object obj)
218 {
219 ConfigurationNode that = (ConfigurationNode) obj;
220 return this.m_Name.CompareTo(that.m_Name);
221 }
222  
223 #endregion
224 }
225 }