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.IO;
28 using System.Xml;
29  
30 using Prebuild.Core.Attributes;
31 using Prebuild.Core.Interfaces;
32 using Prebuild.Core.Utilities;
33 using Prebuild.Core.Targets;
34  
35 namespace Prebuild.Core.Nodes
36 {
37 /// <summary>
38 ///
39 /// </summary>
40 public enum BuildAction
41 {
42 /// <summary>
43 ///
44 /// </summary>
45 None,
46 /// <summary>
47 ///
48 /// </summary>
49 Compile,
50 /// <summary>
51 ///
52 /// </summary>
53 Content,
54 /// <summary>
55 ///
56 /// </summary>
57 EmbeddedResource,
58 /// <summary>
59 ///
60 /// </summary>
61 ApplicationDefinition,
62 /// <summary>
63 ///
64 /// </summary>
65 Page,
66 /// <summary>
67 ///
68 /// </summary>
69 Copy
70 }
71  
72 /// <summary>
73 ///
74 /// </summary>
75 public enum SubType
76 {
77 /// <summary>
78 ///
79 /// </summary>
80 Code,
81 /// <summary>
82 ///
83 /// </summary>
84 Component,
85 /// <summary>
86 ///
87 /// </summary>
88 Designer,
89 /// <summary>
90 ///
91 /// </summary>
92 Form,
93 /// <summary>
94 ///
95 /// </summary>
96 Settings,
97 /// <summary>
98 ///
99 /// </summary>
100 UserControl,
101 /// <summary>
102 ///
103 /// </summary>
104 CodeBehind,
105 }
106  
107 public enum CopyToOutput
108 {
109 Never,
110 Always,
111 PreserveNewest
112 }
113  
114 /// <summary>
115 ///
116 /// </summary>
117 [DataNode("File")]
118 public class FileNode : DataNode
119 {
120 #region Fields
121  
122 private string m_Path;
123 private string m_ResourceName = "";
124 private BuildAction? m_BuildAction;
125 private bool m_Valid;
126 private SubType? m_SubType;
127 private CopyToOutput m_CopyToOutput = CopyToOutput.Never;
128 private bool m_Link = false;
129 private string m_LinkPath = string.Empty;
130 private bool m_PreservePath = false;
131  
132  
133 #endregion
134  
135 #region Properties
136  
137 /// <summary>
138 ///
139 /// </summary>
140 public string Path
141 {
142 get
143 {
144 return m_Path;
145 }
146 }
147  
148 /// <summary>
149 ///
150 /// </summary>
151 public string ResourceName
152 {
153 get
154 {
155 return m_ResourceName;
156 }
157 }
158  
159 /// <summary>
160 ///
161 /// </summary>
162 public BuildAction BuildAction
163 {
164 get
165 {
166 if (m_BuildAction != null)
167 return m_BuildAction.Value;
168 else
169 return GetBuildActionByFileName(this.Path);
170  
171 }
172 }
173  
174 public CopyToOutput CopyToOutput
175 {
176 get
177 {
178 return this.m_CopyToOutput;
179 }
180 }
181  
182 public bool IsLink
183 {
184 get
185 {
186 return this.m_Link;
187 }
188 }
189  
190 public string LinkPath
191 {
192 get
193 {
194 return this.m_LinkPath;
195 }
196 }
197 /// <summary>
198 ///
199 /// </summary>
200 public SubType SubType
201 {
202 get
203 {
204 if (m_SubType != null)
205 return m_SubType.Value;
206 else
207 return GetSubTypeByFileName(this.Path);
208 }
209 }
210  
211 /// <summary>
212 ///
213 /// </summary>
214 public bool IsValid
215 {
216 get
217 {
218 return m_Valid;
219 }
220 }
221  
222 /// <summary>
223 ///
224 /// </summary>
225 /// <param name="file"></param>
226 /// <returns></returns>
227 public bool PreservePath
228 {
229 get
230 {
231 return m_PreservePath;
232 }
233 }
234  
235 #endregion
236  
237 #region Public Methods
238  
239 /// <summary>
240 ///
241 /// </summary>
242 /// <param name="node"></param>
243 public override void Parse(XmlNode node)
244 {
245 string buildAction = Helper.AttributeValue(node, "buildAction", String.Empty);
246 if (buildAction != string.Empty)
247 m_BuildAction = (BuildAction)Enum.Parse(typeof(BuildAction), buildAction);
248 string subType = Helper.AttributeValue(node, "subType", string.Empty);
249 if (subType != String.Empty)
250 m_SubType = (SubType)Enum.Parse(typeof(SubType), subType);
251  
252 Console.WriteLine("[FileNode]:BuildAction is {0}", buildAction);
253  
254  
255 m_ResourceName = Helper.AttributeValue(node, "resourceName", m_ResourceName.ToString());
256 this.m_Link = bool.Parse(Helper.AttributeValue(node, "link", bool.FalseString));
257 if ( this.m_Link == true )
258 {
259 this.m_LinkPath = Helper.AttributeValue( node, "linkPath", string.Empty );
260 }
261 this.m_CopyToOutput = (CopyToOutput) Enum.Parse(typeof(CopyToOutput), Helper.AttributeValue(node, "copyToOutput", this.m_CopyToOutput.ToString()));
262 this.m_PreservePath = bool.Parse( Helper.AttributeValue( node, "preservePath", bool.FalseString ) );
263  
264 if( node == null )
265 {
266 throw new ArgumentNullException("node");
267 }
268  
269 m_Path = Helper.InterpolateForEnvironmentVariables(node.InnerText);
270 if(m_Path == null)
271 {
272 m_Path = "";
273 }
274  
275 m_Path = m_Path.Trim();
276 m_Valid = true;
277 if(!File.Exists(m_Path))
278 {
279 m_Valid = false;
280 Kernel.Instance.Log.Write(LogType.Warning, "File does not exist: {0}", m_Path);
281 }
282  
283 if (System.IO.Path.GetExtension(m_Path) == ".settings")
284 {
285 m_SubType = SubType.Settings;
286 m_BuildAction = BuildAction.None;
287 }
288 }
289  
290 #endregion
291 }
292 }