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