diff options
Diffstat (limited to 'Prebuild/src/Core/Nodes/FilesNode.cs')
-rw-r--r-- | Prebuild/src/Core/Nodes/FilesNode.cs | 247 |
1 files changed, 0 insertions, 247 deletions
diff --git a/Prebuild/src/Core/Nodes/FilesNode.cs b/Prebuild/src/Core/Nodes/FilesNode.cs deleted file mode 100644 index dc306c2..0000000 --- a/Prebuild/src/Core/Nodes/FilesNode.cs +++ /dev/null | |||
@@ -1,247 +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.Collections; | ||
28 | using System.Collections.Specialized; | ||
29 | using System.Xml; | ||
30 | |||
31 | using Prebuild.Core.Attributes; | ||
32 | using Prebuild.Core.Interfaces; | ||
33 | using System.IO; | ||
34 | |||
35 | namespace Prebuild.Core.Nodes | ||
36 | { | ||
37 | /// <summary> | ||
38 | /// | ||
39 | /// </summary> | ||
40 | [DataNode("Files")] | ||
41 | public class FilesNode : DataNode | ||
42 | { | ||
43 | #region Fields | ||
44 | |||
45 | private StringCollection m_Files; | ||
46 | private Hashtable m_BuildActions; | ||
47 | private Hashtable m_SubTypes; | ||
48 | private Hashtable m_ResourceNames; | ||
49 | private Hashtable m_CopyToOutputs; | ||
50 | private Hashtable m_Links; | ||
51 | private Hashtable m_LinkPaths; | ||
52 | private Hashtable m_PreservePaths; | ||
53 | |||
54 | #endregion | ||
55 | |||
56 | #region Constructors | ||
57 | |||
58 | /// <summary> | ||
59 | /// | ||
60 | /// </summary> | ||
61 | public FilesNode() | ||
62 | { | ||
63 | m_Files = new StringCollection(); | ||
64 | m_BuildActions = new Hashtable(); | ||
65 | m_SubTypes = new Hashtable(); | ||
66 | m_ResourceNames = new Hashtable(); | ||
67 | m_CopyToOutputs = new Hashtable(); | ||
68 | m_Links = new Hashtable(); | ||
69 | m_LinkPaths = new Hashtable(); | ||
70 | m_PreservePaths = new Hashtable(); | ||
71 | } | ||
72 | |||
73 | #endregion | ||
74 | |||
75 | #region Properties | ||
76 | |||
77 | /// <summary> | ||
78 | /// | ||
79 | /// </summary> | ||
80 | public int Count | ||
81 | { | ||
82 | get | ||
83 | { | ||
84 | return m_Files.Count; | ||
85 | } | ||
86 | } | ||
87 | |||
88 | #endregion | ||
89 | |||
90 | #region Public Methods | ||
91 | |||
92 | /// <summary> | ||
93 | /// | ||
94 | /// </summary> | ||
95 | /// <param name="file"></param> | ||
96 | /// <returns></returns> | ||
97 | public BuildAction GetBuildAction(string file) | ||
98 | { | ||
99 | if(!m_BuildActions.ContainsKey(file)) | ||
100 | { | ||
101 | return BuildAction.Compile; | ||
102 | } | ||
103 | |||
104 | return (BuildAction)m_BuildActions[file]; | ||
105 | } | ||
106 | |||
107 | public CopyToOutput GetCopyToOutput(string file) | ||
108 | { | ||
109 | if (!this.m_CopyToOutputs.ContainsKey(file)) | ||
110 | { | ||
111 | return CopyToOutput.Never; | ||
112 | } | ||
113 | return (CopyToOutput) this.m_CopyToOutputs[file]; | ||
114 | } | ||
115 | |||
116 | public bool GetIsLink(string file) | ||
117 | { | ||
118 | if (!this.m_Links.ContainsKey(file)) | ||
119 | { | ||
120 | return false; | ||
121 | } | ||
122 | return (bool) this.m_Links[file]; | ||
123 | } | ||
124 | |||
125 | public string GetLinkPath( string file ) | ||
126 | { | ||
127 | if ( !this.m_LinkPaths.ContainsKey( file ) ) | ||
128 | { | ||
129 | return string.Empty; | ||
130 | } | ||
131 | return (string)this.m_LinkPaths[ file ]; | ||
132 | } | ||
133 | |||
134 | /// <summary> | ||
135 | /// | ||
136 | /// </summary> | ||
137 | /// <param name="file"></param> | ||
138 | /// <returns></returns> | ||
139 | public SubType GetSubType(string file) | ||
140 | { | ||
141 | if(!m_SubTypes.ContainsKey(file)) | ||
142 | { | ||
143 | return SubType.Code; | ||
144 | } | ||
145 | |||
146 | return (SubType)m_SubTypes[file]; | ||
147 | } | ||
148 | |||
149 | /// <summary> | ||
150 | /// | ||
151 | /// </summary> | ||
152 | /// <param name="file"></param> | ||
153 | /// <returns></returns> | ||
154 | public string GetResourceName(string file) | ||
155 | { | ||
156 | if(!m_ResourceNames.ContainsKey(file)) | ||
157 | { | ||
158 | return ""; | ||
159 | } | ||
160 | |||
161 | return (string)m_ResourceNames[file]; | ||
162 | } | ||
163 | |||
164 | /// <summary> | ||
165 | /// | ||
166 | /// </summary> | ||
167 | /// <param name="file"></param> | ||
168 | /// <returns></returns> | ||
169 | public bool GetPreservePath( string file ) | ||
170 | { | ||
171 | if ( !m_PreservePaths.ContainsKey( file ) ) | ||
172 | { | ||
173 | return false; | ||
174 | } | ||
175 | |||
176 | return (bool)m_PreservePaths[ file ]; | ||
177 | } | ||
178 | |||
179 | /// <summary> | ||
180 | /// | ||
181 | /// </summary> | ||
182 | /// <param name="node"></param> | ||
183 | public override void Parse(XmlNode node) | ||
184 | { | ||
185 | if( node == null ) | ||
186 | { | ||
187 | throw new ArgumentNullException("node"); | ||
188 | } | ||
189 | foreach(XmlNode child in node.ChildNodes) | ||
190 | { | ||
191 | IDataNode dataNode = Kernel.Instance.ParseNode(child, this); | ||
192 | if(dataNode is FileNode) | ||
193 | { | ||
194 | FileNode fileNode = (FileNode)dataNode; | ||
195 | if(fileNode.IsValid) | ||
196 | { | ||
197 | if (!m_Files.Contains(fileNode.Path)) | ||
198 | { | ||
199 | m_Files.Add(fileNode.Path); | ||
200 | m_BuildActions[fileNode.Path] = fileNode.BuildAction; | ||
201 | m_SubTypes[fileNode.Path] = fileNode.SubType; | ||
202 | m_ResourceNames[fileNode.Path] = fileNode.ResourceName; | ||
203 | this.m_PreservePaths[ fileNode.Path ] = fileNode.PreservePath; | ||
204 | this.m_Links[ fileNode.Path ] = fileNode.IsLink; | ||
205 | this.m_LinkPaths[ fileNode.Path ] = fileNode.LinkPath; | ||
206 | this.m_CopyToOutputs[ fileNode.Path ] = fileNode.CopyToOutput; | ||
207 | |||
208 | } | ||
209 | } | ||
210 | } | ||
211 | else if(dataNode is MatchNode) | ||
212 | { | ||
213 | foreach(string file in ((MatchNode)dataNode).Files) | ||
214 | { | ||
215 | MatchNode matchNode = (MatchNode)dataNode; | ||
216 | if (!m_Files.Contains(file)) | ||
217 | { | ||
218 | m_Files.Add(file); | ||
219 | m_BuildActions[ file ] = matchNode.BuildAction == null ? GetBuildActionByFileName(file) : matchNode.BuildAction; | ||
220 | m_SubTypes[file] = matchNode.SubType == null ? GetSubTypeByFileName(file) : matchNode.SubType.Value; | ||
221 | m_ResourceNames[ file ] = matchNode.ResourceName; | ||
222 | this.m_PreservePaths[ file ] = matchNode.PreservePath; | ||
223 | this.m_Links[ file ] = matchNode.IsLink; | ||
224 | this.m_LinkPaths[ file ] = matchNode.LinkPath; | ||
225 | this.m_CopyToOutputs[ file ] = matchNode.CopyToOutput; | ||
226 | |||
227 | } | ||
228 | } | ||
229 | } | ||
230 | } | ||
231 | } | ||
232 | |||
233 | // TODO: Check in to why StringCollection's enumerator doesn't implement | ||
234 | // IEnumerator? | ||
235 | /// <summary> | ||
236 | /// | ||
237 | /// </summary> | ||
238 | /// <returns></returns> | ||
239 | public StringEnumerator GetEnumerator() | ||
240 | { | ||
241 | return m_Files.GetEnumerator(); | ||
242 | } | ||
243 | |||
244 | #endregion | ||
245 | |||
246 | } | ||
247 | } | ||