diff options
Diffstat (limited to 'Prebuild/src/Core/Nodes/FileNode.cs')
-rw-r--r-- | Prebuild/src/Core/Nodes/FileNode.cs | 271 |
1 files changed, 0 insertions, 271 deletions
diff --git a/Prebuild/src/Core/Nodes/FileNode.cs b/Prebuild/src/Core/Nodes/FileNode.cs deleted file mode 100644 index 1520fcb..0000000 --- a/Prebuild/src/Core/Nodes/FileNode.cs +++ /dev/null | |||
@@ -1,271 +0,0 @@ | |||
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 | } | ||
59 | |||
60 | /// <summary> | ||
61 | /// | ||
62 | /// </summary> | ||
63 | public enum SubType | ||
64 | { | ||
65 | /// <summary> | ||
66 | /// | ||
67 | /// </summary> | ||
68 | Code, | ||
69 | /// <summary> | ||
70 | /// | ||
71 | /// </summary> | ||
72 | Component, | ||
73 | /// <summary> | ||
74 | /// | ||
75 | /// </summary> | ||
76 | Designer, | ||
77 | /// <summary> | ||
78 | /// | ||
79 | /// </summary> | ||
80 | Form, | ||
81 | /// <summary> | ||
82 | /// | ||
83 | /// </summary> | ||
84 | Settings, | ||
85 | /// <summary> | ||
86 | /// | ||
87 | /// </summary> | ||
88 | UserControl, | ||
89 | /// <summary> | ||
90 | /// | ||
91 | /// </summary> | ||
92 | CodeBehind, | ||
93 | } | ||
94 | |||
95 | public enum CopyToOutput | ||
96 | { | ||
97 | Never, | ||
98 | Always, | ||
99 | PreserveNewest | ||
100 | } | ||
101 | |||
102 | /// <summary> | ||
103 | /// | ||
104 | /// </summary> | ||
105 | [DataNode("File")] | ||
106 | public class FileNode : DataNode | ||
107 | { | ||
108 | #region Fields | ||
109 | |||
110 | private string m_Path; | ||
111 | private string m_ResourceName = ""; | ||
112 | private BuildAction? m_BuildAction; | ||
113 | private bool m_Valid; | ||
114 | private SubType? m_SubType; | ||
115 | private CopyToOutput m_CopyToOutput = CopyToOutput.Never; | ||
116 | private bool m_Link = false; | ||
117 | private string m_LinkPath = string.Empty; | ||
118 | private bool m_PreservePath = false; | ||
119 | |||
120 | |||
121 | #endregion | ||
122 | |||
123 | #region Properties | ||
124 | |||
125 | /// <summary> | ||
126 | /// | ||
127 | /// </summary> | ||
128 | public string Path | ||
129 | { | ||
130 | get | ||
131 | { | ||
132 | return m_Path; | ||
133 | } | ||
134 | } | ||
135 | |||
136 | /// <summary> | ||
137 | /// | ||
138 | /// </summary> | ||
139 | public string ResourceName | ||
140 | { | ||
141 | get | ||
142 | { | ||
143 | return m_ResourceName; | ||
144 | } | ||
145 | } | ||
146 | |||
147 | /// <summary> | ||
148 | /// | ||
149 | /// </summary> | ||
150 | public BuildAction BuildAction | ||
151 | { | ||
152 | get | ||
153 | { | ||
154 | if (m_BuildAction != null) | ||
155 | return m_BuildAction.Value; | ||
156 | else | ||
157 | return GetBuildActionByFileName(this.Path); | ||
158 | |||
159 | } | ||
160 | } | ||
161 | |||
162 | public CopyToOutput CopyToOutput | ||
163 | { | ||
164 | get | ||
165 | { | ||
166 | return this.m_CopyToOutput; | ||
167 | } | ||
168 | } | ||
169 | |||
170 | public bool IsLink | ||
171 | { | ||
172 | get | ||
173 | { | ||
174 | return this.m_Link; | ||
175 | } | ||
176 | } | ||
177 | |||
178 | public string LinkPath | ||
179 | { | ||
180 | get | ||
181 | { | ||
182 | return this.m_LinkPath; | ||
183 | } | ||
184 | } | ||
185 | /// <summary> | ||
186 | /// | ||
187 | /// </summary> | ||
188 | public SubType SubType | ||
189 | { | ||
190 | get | ||
191 | { | ||
192 | if (m_SubType != null) | ||
193 | return m_SubType.Value; | ||
194 | else | ||
195 | return GetSubTypeByFileName(this.Path); | ||
196 | } | ||
197 | } | ||
198 | |||
199 | /// <summary> | ||
200 | /// | ||
201 | /// </summary> | ||
202 | public bool IsValid | ||
203 | { | ||
204 | get | ||
205 | { | ||
206 | return m_Valid; | ||
207 | } | ||
208 | } | ||
209 | |||
210 | /// <summary> | ||
211 | /// | ||
212 | /// </summary> | ||
213 | /// <param name="file"></param> | ||
214 | /// <returns></returns> | ||
215 | public bool PreservePath | ||
216 | { | ||
217 | get | ||
218 | { | ||
219 | return m_PreservePath; | ||
220 | } | ||
221 | } | ||
222 | |||
223 | #endregion | ||
224 | |||
225 | #region Public Methods | ||
226 | |||
227 | /// <summary> | ||
228 | /// | ||
229 | /// </summary> | ||
230 | /// <param name="node"></param> | ||
231 | public override void Parse(XmlNode node) | ||
232 | { | ||
233 | string buildAction = Helper.AttributeValue(node, "buildAction", String.Empty); | ||
234 | if (buildAction != string.Empty) | ||
235 | m_BuildAction = (BuildAction)Enum.Parse(typeof(BuildAction), buildAction); | ||
236 | string subType = Helper.AttributeValue(node, "subType", string.Empty); | ||
237 | if (subType != String.Empty) | ||
238 | m_SubType = (SubType)Enum.Parse(typeof(SubType), subType); | ||
239 | |||
240 | m_ResourceName = Helper.AttributeValue(node, "resourceName", m_ResourceName.ToString()); | ||
241 | this.m_Link = bool.Parse(Helper.AttributeValue(node, "link", bool.FalseString)); | ||
242 | if ( this.m_Link == true ) | ||
243 | { | ||
244 | this.m_LinkPath = Helper.AttributeValue( node, "linkPath", string.Empty ); | ||
245 | } | ||
246 | this.m_CopyToOutput = (CopyToOutput) Enum.Parse(typeof(CopyToOutput), Helper.AttributeValue(node, "copyToOutput", this.m_CopyToOutput.ToString())); | ||
247 | this.m_PreservePath = bool.Parse( Helper.AttributeValue( node, "preservePath", bool.FalseString ) ); | ||
248 | |||
249 | if( node == null ) | ||
250 | { | ||
251 | throw new ArgumentNullException("node"); | ||
252 | } | ||
253 | |||
254 | m_Path = Helper.InterpolateForEnvironmentVariables(node.InnerText); | ||
255 | if(m_Path == null) | ||
256 | { | ||
257 | m_Path = ""; | ||
258 | } | ||
259 | |||
260 | m_Path = m_Path.Trim(); | ||
261 | m_Valid = true; | ||
262 | if(!File.Exists(m_Path)) | ||
263 | { | ||
264 | m_Valid = false; | ||
265 | Kernel.Instance.Log.Write(LogType.Warning, "File does not exist: {0}", m_Path); | ||
266 | } | ||
267 | } | ||
268 | |||
269 | #endregion | ||
270 | } | ||
271 | } | ||