aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Prebuild/src/Core/Nodes/FileNode.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Prebuild/src/Core/Nodes/FileNode.cs')
-rw-r--r--Prebuild/src/Core/Nodes/FileNode.cs238
1 files changed, 238 insertions, 0 deletions
diff --git a/Prebuild/src/Core/Nodes/FileNode.cs b/Prebuild/src/Core/Nodes/FileNode.cs
new file mode 100644
index 0000000..de3b69e
--- /dev/null
+++ b/Prebuild/src/Core/Nodes/FileNode.cs
@@ -0,0 +1,238 @@
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: 2007-01-08 17:55:40 +0100 (må, 08 jan 2007) $
31 * $Revision: 197 $
32 */
33#endregion
34
35using System;
36using System.IO;
37using System.Xml;
38
39using Prebuild.Core.Attributes;
40using Prebuild.Core.Interfaces;
41using Prebuild.Core.Utilities;
42
43namespace Prebuild.Core.Nodes
44{
45 /// <summary>
46 ///
47 /// </summary>
48 public enum BuildAction
49 {
50 /// <summary>
51 ///
52 /// </summary>
53 None,
54 /// <summary>
55 ///
56 /// </summary>
57 Compile,
58 /// <summary>
59 ///
60 /// </summary>
61 Content,
62 /// <summary>
63 ///
64 /// </summary>
65 EmbeddedResource
66 }
67
68 /// <summary>
69 ///
70 /// </summary>
71 public enum SubType
72 {
73 /// <summary>
74 ///
75 /// </summary>
76 Code,
77 /// <summary>
78 ///
79 /// </summary>
80 Component,
81 /// <summary>
82 ///
83 /// </summary>
84 Designer,
85 /// <summary>
86 ///
87 /// </summary>
88 Form,
89 /// <summary>
90 ///
91 /// </summary>
92 Settings,
93 /// <summary>
94 ///
95 /// </summary>
96 UserControl
97 }
98
99 public enum CopyToOutput
100 {
101 Never,
102 Always,
103 PreserveNewest
104 }
105
106 /// <summary>
107 ///
108 /// </summary>
109 [DataNode("File")]
110 public class FileNode : DataNode
111 {
112 #region Fields
113
114 private string m_Path;
115 private string m_ResourceName = "";
116 private BuildAction m_BuildAction = BuildAction.Compile;
117 private bool m_Valid;
118 private SubType m_SubType = SubType.Code;
119 private CopyToOutput m_CopyToOutput = CopyToOutput.Never;
120 private bool m_Link = false;
121
122
123 #endregion
124
125 #region Properties
126
127 /// <summary>
128 ///
129 /// </summary>
130 public string Path
131 {
132 get
133 {
134 return m_Path;
135 }
136 }
137
138 /// <summary>
139 ///
140 /// </summary>
141 public string ResourceName
142 {
143 get
144 {
145 return m_ResourceName;
146 }
147 }
148
149 /// <summary>
150 ///
151 /// </summary>
152 public BuildAction BuildAction
153 {
154 get
155 {
156 return m_BuildAction;
157 }
158 }
159
160 public CopyToOutput CopyToOutput
161 {
162 get
163 {
164 return this.m_CopyToOutput;
165 }
166 }
167
168 public bool IsLink
169 {
170 get
171 {
172 return this.m_Link;
173 }
174 }
175
176 /// <summary>
177 ///
178 /// </summary>
179 public SubType SubType
180 {
181 get
182 {
183 return m_SubType;
184 }
185 }
186
187 /// <summary>
188 ///
189 /// </summary>
190 public bool IsValid
191 {
192 get
193 {
194 return m_Valid;
195 }
196 }
197
198 #endregion
199
200 #region Public Methods
201
202 /// <summary>
203 ///
204 /// </summary>
205 /// <param name="node"></param>
206 public override void Parse(XmlNode node)
207 {
208 m_BuildAction = (BuildAction)Enum.Parse(typeof(BuildAction),
209 Helper.AttributeValue(node, "buildAction", m_BuildAction.ToString()));
210 m_SubType = (SubType)Enum.Parse(typeof(SubType),
211 Helper.AttributeValue(node, "subType", m_SubType.ToString()));
212 m_ResourceName = Helper.AttributeValue(node, "resourceName", m_ResourceName.ToString());
213 this.m_Link = bool.Parse(Helper.AttributeValue(node, "link", bool.FalseString));
214 this.m_CopyToOutput = (CopyToOutput) Enum.Parse(typeof(CopyToOutput), Helper.AttributeValue(node, "copyToOutput", this.m_CopyToOutput.ToString()));
215
216 if( node == null )
217 {
218 throw new ArgumentNullException("node");
219 }
220
221 m_Path = Helper.InterpolateForEnvironmentVariables(node.InnerText);
222 if(m_Path == null)
223 {
224 m_Path = "";
225 }
226
227 m_Path = m_Path.Trim();
228 m_Valid = true;
229 if(!File.Exists(m_Path))
230 {
231 m_Valid = false;
232 Kernel.Instance.Log.Write(LogType.Warning, "File does not exist: {0}", m_Path);
233 }
234 }
235
236 #endregion
237 }
238}