diff options
Diffstat (limited to 'Prebuild/src/Core/Nodes/FileNode.cs')
-rw-r--r-- | Prebuild/src/Core/Nodes/FileNode.cs | 456 |
1 files changed, 228 insertions, 228 deletions
diff --git a/Prebuild/src/Core/Nodes/FileNode.cs b/Prebuild/src/Core/Nodes/FileNode.cs index b313ffa..c66f123 100644 --- a/Prebuild/src/Core/Nodes/FileNode.cs +++ b/Prebuild/src/Core/Nodes/FileNode.cs | |||
@@ -5,16 +5,16 @@ Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehea | |||
5 | Redistribution and use in source and binary forms, with or without modification, are permitted | 5 | Redistribution and use in source and binary forms, with or without modification, are permitted |
6 | provided that the following conditions are met: | 6 | provided that the following conditions are met: |
7 | 7 | ||
8 | * Redistributions of source code must retain the above copyright notice, this list of conditions | 8 | * Redistributions of source code must retain the above copyright notice, this list of conditions |
9 | and the following disclaimer. | 9 | and the following disclaimer. |
10 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions | 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 | 11 | and the following disclaimer in the documentation and/or other materials provided with the |
12 | distribution. | 12 | distribution. |
13 | * The name of the author may not be used to endorse or promote products derived from this software | 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. | 14 | without specific prior written permission. |
15 | 15 | ||
16 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | 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 | 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, | 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 | 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 | 20 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
@@ -34,193 +34,193 @@ using Prebuild.Core.Targets; | |||
34 | 34 | ||
35 | namespace Prebuild.Core.Nodes | 35 | namespace Prebuild.Core.Nodes |
36 | { | 36 | { |
37 | /// <summary> | 37 | /// <summary> |
38 | /// | 38 | /// |
39 | /// </summary> | 39 | /// </summary> |
40 | public enum BuildAction | 40 | public enum BuildAction |
41 | { | 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> | 42 | /// <summary> |
67 | /// | 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> | 68 | /// </summary> |
69 | Copy | 69 | Copy |
70 | } | 70 | } |
71 | 71 | ||
72 | /// <summary> | 72 | /// <summary> |
73 | /// | 73 | /// |
74 | /// </summary> | 74 | /// </summary> |
75 | public enum SubType | 75 | public enum SubType |
76 | { | 76 | { |
77 | /// <summary> | ||
78 | /// | ||
79 | /// </summary> | ||
80 | Code, | ||
81 | /// <summary> | ||
82 | /// | ||
83 | /// </summary> | ||
84 | Component, | ||
85 | /// <summary> | 77 | /// <summary> |
86 | /// | 78 | /// |
79 | /// </summary> | ||
80 | Code, | ||
81 | /// <summary> | ||
82 | /// | ||
83 | /// </summary> | ||
84 | Component, | ||
85 | /// <summary> | ||
86 | /// | ||
87 | /// </summary> | 87 | /// </summary> |
88 | Designer, | 88 | Designer, |
89 | /// <summary> | 89 | /// <summary> |
90 | /// | 90 | /// |
91 | /// </summary> | 91 | /// </summary> |
92 | Form, | 92 | Form, |
93 | /// <summary> | 93 | /// <summary> |
94 | /// | 94 | /// |
95 | /// </summary> | 95 | /// </summary> |
96 | Settings, | 96 | Settings, |
97 | /// <summary> | 97 | /// <summary> |
98 | /// | 98 | /// |
99 | /// </summary> | 99 | /// </summary> |
100 | UserControl, | 100 | UserControl, |
101 | /// <summary> | 101 | /// <summary> |
102 | /// | 102 | /// |
103 | /// </summary> | 103 | /// </summary> |
104 | CodeBehind, | 104 | CodeBehind, |
105 | } | 105 | } |
106 | 106 | ||
107 | public enum CopyToOutput | 107 | public enum CopyToOutput |
108 | { | 108 | { |
109 | Never, | 109 | Never, |
110 | Always, | 110 | Always, |
111 | PreserveNewest | 111 | PreserveNewest |
112 | } | 112 | } |
113 | 113 | ||
114 | /// <summary> | 114 | /// <summary> |
115 | /// | 115 | /// |
116 | /// </summary> | 116 | /// </summary> |
117 | [DataNode("File")] | 117 | [DataNode("File")] |
118 | public class FileNode : DataNode | 118 | public class FileNode : DataNode |
119 | { | 119 | { |
120 | #region Fields | 120 | #region Fields |
121 | 121 | ||
122 | private string m_Path; | 122 | private string m_Path; |
123 | private string m_ResourceName = ""; | 123 | private string m_ResourceName = ""; |
124 | private BuildAction? m_BuildAction; | 124 | private BuildAction? m_BuildAction; |
125 | private bool m_Valid; | 125 | private bool m_Valid; |
126 | private SubType? m_SubType; | 126 | private SubType? m_SubType; |
127 | private CopyToOutput m_CopyToOutput = CopyToOutput.Never; | 127 | private CopyToOutput m_CopyToOutput = CopyToOutput.Never; |
128 | private bool m_Link = false; | 128 | private bool m_Link = false; |
129 | private string m_LinkPath = string.Empty; | 129 | private string m_LinkPath = string.Empty; |
130 | private bool m_PreservePath = false; | 130 | private bool m_PreservePath = false; |
131 | 131 | ||
132 | 132 | ||
133 | #endregion | 133 | #endregion |
134 | 134 | ||
135 | #region Properties | 135 | #region Properties |
136 | 136 | ||
137 | /// <summary> | 137 | /// <summary> |
138 | /// | 138 | /// |
139 | /// </summary> | 139 | /// </summary> |
140 | public string Path | 140 | public string Path |
141 | { | 141 | { |
142 | get | 142 | get |
143 | { | 143 | { |
144 | return m_Path; | 144 | return m_Path; |
145 | } | 145 | } |
146 | } | 146 | } |
147 | 147 | ||
148 | /// <summary> | 148 | /// <summary> |
149 | /// | 149 | /// |
150 | /// </summary> | 150 | /// </summary> |
151 | public string ResourceName | 151 | public string ResourceName |
152 | { | 152 | { |
153 | get | 153 | get |
154 | { | 154 | { |
155 | return m_ResourceName; | 155 | return m_ResourceName; |
156 | } | 156 | } |
157 | } | 157 | } |
158 | 158 | ||
159 | /// <summary> | 159 | /// <summary> |
160 | /// | 160 | /// |
161 | /// </summary> | 161 | /// </summary> |
162 | public BuildAction BuildAction | 162 | public BuildAction BuildAction |
163 | { | 163 | { |
164 | get | 164 | get |
165 | { | 165 | { |
166 | if (m_BuildAction != null) | 166 | if (m_BuildAction != null) |
167 | return m_BuildAction.Value; | 167 | return m_BuildAction.Value; |
168 | else | 168 | else |
169 | return GetBuildActionByFileName(this.Path); | 169 | return GetBuildActionByFileName(this.Path); |
170 | 170 | ||
171 | } | 171 | } |
172 | } | 172 | } |
173 | 173 | ||
174 | public CopyToOutput CopyToOutput | 174 | public CopyToOutput CopyToOutput |
175 | { | 175 | { |
176 | get | 176 | get |
177 | { | 177 | { |
178 | return this.m_CopyToOutput; | 178 | return this.m_CopyToOutput; |
179 | } | 179 | } |
180 | } | 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 | 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 | } | ||
222 | /// <summary> | 197 | /// <summary> |
223 | /// | 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> | 224 | /// </summary> |
225 | /// <param name="file"></param> | 225 | /// <param name="file"></param> |
226 | /// <returns></returns> | 226 | /// <returns></returns> |
@@ -232,61 +232,61 @@ namespace Prebuild.Core.Nodes | |||
232 | } | 232 | } |
233 | } | 233 | } |
234 | 234 | ||
235 | #endregion | 235 | #endregion |
236 | 236 | ||
237 | #region Public Methods | 237 | #region Public Methods |
238 | 238 | ||
239 | /// <summary> | 239 | /// <summary> |
240 | /// | 240 | /// |
241 | /// </summary> | 241 | /// </summary> |
242 | /// <param name="node"></param> | 242 | /// <param name="node"></param> |
243 | public override void Parse(XmlNode node) | 243 | public override void Parse(XmlNode node) |
244 | { | 244 | { |
245 | string buildAction = Helper.AttributeValue(node, "buildAction", String.Empty); | 245 | string buildAction = Helper.AttributeValue(node, "buildAction", String.Empty); |
246 | if (buildAction != string.Empty) | 246 | if (buildAction != string.Empty) |
247 | m_BuildAction = (BuildAction)Enum.Parse(typeof(BuildAction), buildAction); | 247 | m_BuildAction = (BuildAction)Enum.Parse(typeof(BuildAction), buildAction); |
248 | string subType = Helper.AttributeValue(node, "subType", string.Empty); | 248 | string subType = Helper.AttributeValue(node, "subType", string.Empty); |
249 | if (subType != String.Empty) | 249 | if (subType != String.Empty) |
250 | m_SubType = (SubType)Enum.Parse(typeof(SubType), subType); | 250 | m_SubType = (SubType)Enum.Parse(typeof(SubType), subType); |
251 | 251 | ||
252 | Console.WriteLine("[FileNode]:BuildAction is {0}", buildAction); | 252 | Console.WriteLine("[FileNode]:BuildAction is {0}", buildAction); |
253 | 253 | ||
254 | 254 | ||
255 | m_ResourceName = Helper.AttributeValue(node, "resourceName", m_ResourceName.ToString()); | 255 | m_ResourceName = Helper.AttributeValue(node, "resourceName", m_ResourceName.ToString()); |
256 | this.m_Link = bool.Parse(Helper.AttributeValue(node, "link", bool.FalseString)); | 256 | this.m_Link = bool.Parse(Helper.AttributeValue(node, "link", bool.FalseString)); |
257 | if ( this.m_Link == true ) | 257 | if ( this.m_Link == true ) |
258 | { | 258 | { |
259 | this.m_LinkPath = Helper.AttributeValue( node, "linkPath", string.Empty ); | 259 | this.m_LinkPath = Helper.AttributeValue( node, "linkPath", string.Empty ); |
260 | } | 260 | } |
261 | this.m_CopyToOutput = (CopyToOutput) Enum.Parse(typeof(CopyToOutput), Helper.AttributeValue(node, "copyToOutput", this.m_CopyToOutput.ToString())); | 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 ) ); | 262 | this.m_PreservePath = bool.Parse( Helper.AttributeValue( node, "preservePath", bool.FalseString ) ); |
263 | 263 | ||
264 | if( node == null ) | 264 | if( node == null ) |
265 | { | 265 | { |
266 | throw new ArgumentNullException("node"); | 266 | throw new ArgumentNullException("node"); |
267 | } | 267 | } |
268 | 268 | ||
269 | m_Path = Helper.InterpolateForEnvironmentVariables(node.InnerText); | 269 | m_Path = Helper.InterpolateForEnvironmentVariables(node.InnerText); |
270 | if(m_Path == null) | 270 | if(m_Path == null) |
271 | { | 271 | { |
272 | m_Path = ""; | 272 | m_Path = ""; |
273 | } | 273 | } |
274 | 274 | ||
275 | m_Path = m_Path.Trim(); | 275 | m_Path = m_Path.Trim(); |
276 | m_Valid = true; | 276 | m_Valid = true; |
277 | if(!File.Exists(m_Path)) | 277 | if(!File.Exists(m_Path)) |
278 | { | 278 | { |
279 | m_Valid = false; | 279 | m_Valid = false; |
280 | Kernel.Instance.Log.Write(LogType.Warning, "File does not exist: {0}", m_Path); | 280 | Kernel.Instance.Log.Write(LogType.Warning, "File does not exist: {0}", m_Path); |
281 | } | 281 | } |
282 | 282 | ||
283 | if (System.IO.Path.GetExtension(m_Path) == ".settings") | 283 | if (System.IO.Path.GetExtension(m_Path) == ".settings") |
284 | { | 284 | { |
285 | m_SubType = SubType.Settings; | 285 | m_SubType = SubType.Settings; |
286 | m_BuildAction = BuildAction.None; | 286 | m_BuildAction = BuildAction.None; |
287 | } | 287 | } |
288 | } | 288 | } |
289 | 289 | ||
290 | #endregion | 290 | #endregion |
291 | } | 291 | } |
292 | } | 292 | } |