aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Prebuild/src/Core/Nodes/FilesNode.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Prebuild/src/Core/Nodes/FilesNode.cs284
1 files changed, 142 insertions, 142 deletions
diff --git a/Prebuild/src/Core/Nodes/FilesNode.cs b/Prebuild/src/Core/Nodes/FilesNode.cs
index 16658f3..58b54fb 100644
--- a/Prebuild/src/Core/Nodes/FilesNode.cs
+++ b/Prebuild/src/Core/Nodes/FilesNode.cs
@@ -5,16 +5,16 @@ Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehea
5Redistribution and use in source and binary forms, with or without modification, are permitted 5Redistribution and use in source and binary forms, with or without modification, are permitted
6provided that the following conditions are met: 6provided 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
16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 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 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, 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 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 20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
@@ -34,36 +34,36 @@ using System.IO;
34 34
35namespace Prebuild.Core.Nodes 35namespace Prebuild.Core.Nodes
36{ 36{
37 /// <summary> 37 /// <summary>
38 /// 38 ///
39 /// </summary> 39 /// </summary>
40 [DataNode("Files")] 40 [DataNode("Files")]
41 public class FilesNode : DataNode 41 public class FilesNode : DataNode
42 { 42 {
43 #region Fields 43 #region Fields
44 44
45 private readonly List<string> m_Files = new List<string>(); 45 private readonly List<string> m_Files = new List<string>();
46 private readonly Dictionary<string,BuildAction> m_BuildActions = new Dictionary<string, BuildAction>(); 46 private readonly Dictionary<string,BuildAction> m_BuildActions = new Dictionary<string, BuildAction>();
47 private readonly Dictionary<string, SubType> m_SubTypes = new Dictionary<string, SubType>(); 47 private readonly Dictionary<string, SubType> m_SubTypes = new Dictionary<string, SubType>();
48 private readonly Dictionary<string, string> m_ResourceNames = new Dictionary<string, string>(); 48 private readonly Dictionary<string, string> m_ResourceNames = new Dictionary<string, string>();
49 private readonly Dictionary<string, CopyToOutput> m_CopyToOutputs = new Dictionary<string, CopyToOutput>(); 49 private readonly Dictionary<string, CopyToOutput> m_CopyToOutputs = new Dictionary<string, CopyToOutput>();
50 private readonly Dictionary<string, bool> m_Links = new Dictionary<string, bool>(); 50 private readonly Dictionary<string, bool> m_Links = new Dictionary<string, bool>();
51 private readonly Dictionary<string, string> m_LinkPaths = new Dictionary<string, string>(); 51 private readonly Dictionary<string, string> m_LinkPaths = new Dictionary<string, string>();
52 private readonly Dictionary<string, bool> m_PreservePaths = new Dictionary<string, bool>(); 52 private readonly Dictionary<string, bool> m_PreservePaths = new Dictionary<string, bool>();
53 private readonly Dictionary<string, string> m_DestinationPath = new Dictionary<string, string>(); 53 private readonly Dictionary<string, string> m_DestinationPath = new Dictionary<string, string>();
54 private readonly NameValueCollection m_CopyFiles = new NameValueCollection(); 54 private readonly NameValueCollection m_CopyFiles = new NameValueCollection();
55 55
56 #endregion 56 #endregion
57 57
58 #region Properties 58 #region Properties
59 59
60 public int Count 60 public int Count
61 { 61 {
62 get 62 get
63 { 63 {
64 return m_Files.Count; 64 return m_Files.Count;
65 } 65 }
66 } 66 }
67 67
68 public string[] Destinations 68 public string[] Destinations
69 { 69 {
@@ -75,19 +75,19 @@ namespace Prebuild.Core.Nodes
75 get { return m_CopyFiles.Count; } 75 get { return m_CopyFiles.Count; }
76 } 76 }
77 77
78 #endregion 78 #endregion
79 79
80 #region Public Methods 80 #region Public Methods
81 81
82 public BuildAction GetBuildAction(string file) 82 public BuildAction GetBuildAction(string file)
83 { 83 {
84 if(!m_BuildActions.ContainsKey(file)) 84 if(!m_BuildActions.ContainsKey(file))
85 { 85 {
86 return BuildAction.Compile; 86 return BuildAction.Compile;
87 } 87 }
88 88
89 return m_BuildActions[file]; 89 return m_BuildActions[file];
90 } 90 }
91 91
92 public string GetDestinationPath(string file) 92 public string GetDestinationPath(string file)
93 { 93 {
@@ -103,57 +103,57 @@ namespace Prebuild.Core.Nodes
103 return m_CopyFiles.GetValues(dest); 103 return m_CopyFiles.GetValues(dest);
104 } 104 }
105 105
106 public CopyToOutput GetCopyToOutput(string file) 106 public CopyToOutput GetCopyToOutput(string file)
107 { 107 {
108 if (!m_CopyToOutputs.ContainsKey(file)) 108 if (!m_CopyToOutputs.ContainsKey(file))
109 { 109 {
110 return CopyToOutput.Never; 110 return CopyToOutput.Never;
111 } 111 }
112 return m_CopyToOutputs[file]; 112 return m_CopyToOutputs[file];
113 } 113 }
114 114
115 public bool GetIsLink(string file) 115 public bool GetIsLink(string file)
116 { 116 {
117 if (!m_Links.ContainsKey(file)) 117 if (!m_Links.ContainsKey(file))
118 { 118 {
119 return false; 119 return false;
120 } 120 }
121 return m_Links[file]; 121 return m_Links[file];
122 } 122 }
123 123
124 public bool Contains(string file) 124 public bool Contains(string file)
125 { 125 {
126 return m_Files.Contains(file); 126 return m_Files.Contains(file);
127 } 127 }
128 128
129 public string GetLinkPath( string file ) 129 public string GetLinkPath( string file )
130 { 130 {
131 if ( !m_LinkPaths.ContainsKey( file ) ) 131 if ( !m_LinkPaths.ContainsKey( file ) )
132 { 132 {
133 return string.Empty; 133 return string.Empty;
134 } 134 }
135 return m_LinkPaths[ file ]; 135 return m_LinkPaths[ file ];
136 } 136 }
137 137
138 public SubType GetSubType(string file) 138 public SubType GetSubType(string file)
139 { 139 {
140 if(!m_SubTypes.ContainsKey(file)) 140 if(!m_SubTypes.ContainsKey(file))
141 { 141 {
142 return SubType.Code; 142 return SubType.Code;
143 } 143 }
144 144
145 return m_SubTypes[file]; 145 return m_SubTypes[file];
146 } 146 }
147 147
148 public string GetResourceName(string file) 148 public string GetResourceName(string file)
149 { 149 {
150 if(!m_ResourceNames.ContainsKey(file)) 150 if(!m_ResourceNames.ContainsKey(file))
151 { 151 {
152 return string.Empty; 152 return string.Empty;
153 } 153 }
154 154
155 return m_ResourceNames[file]; 155 return m_ResourceNames[file];
156 } 156 }
157 157
158 public bool GetPreservePath( string file ) 158 public bool GetPreservePath( string file )
159 { 159 {
@@ -165,45 +165,45 @@ namespace Prebuild.Core.Nodes
165 return m_PreservePaths[ file ]; 165 return m_PreservePaths[ file ];
166 } 166 }
167 167
168 public override void Parse(XmlNode node) 168 public override void Parse(XmlNode node)
169 { 169 {
170 if( node == null ) 170 if( node == null )
171 { 171 {
172 throw new ArgumentNullException("node"); 172 throw new ArgumentNullException("node");
173 } 173 }
174 foreach(XmlNode child in node.ChildNodes) 174 foreach(XmlNode child in node.ChildNodes)
175 { 175 {
176 IDataNode dataNode = Kernel.Instance.ParseNode(child, this); 176 IDataNode dataNode = Kernel.Instance.ParseNode(child, this);
177 if(dataNode is FileNode) 177 if(dataNode is FileNode)
178 { 178 {
179 FileNode fileNode = (FileNode)dataNode; 179 FileNode fileNode = (FileNode)dataNode;
180 if(fileNode.IsValid) 180 if(fileNode.IsValid)
181 { 181 {
182 if (!m_Files.Contains(fileNode.Path)) 182 if (!m_Files.Contains(fileNode.Path))
183 { 183 {
184 m_Files.Add(fileNode.Path); 184 m_Files.Add(fileNode.Path);
185 m_BuildActions[fileNode.Path] = fileNode.BuildAction; 185 m_BuildActions[fileNode.Path] = fileNode.BuildAction;
186 m_SubTypes[fileNode.Path] = fileNode.SubType; 186 m_SubTypes[fileNode.Path] = fileNode.SubType;
187 m_ResourceNames[fileNode.Path] = fileNode.ResourceName; 187 m_ResourceNames[fileNode.Path] = fileNode.ResourceName;
188 m_PreservePaths[ fileNode.Path ] = fileNode.PreservePath; 188 m_PreservePaths[ fileNode.Path ] = fileNode.PreservePath;
189 m_Links[ fileNode.Path ] = fileNode.IsLink; 189 m_Links[ fileNode.Path ] = fileNode.IsLink;
190 m_LinkPaths[ fileNode.Path ] = fileNode.LinkPath; 190 m_LinkPaths[ fileNode.Path ] = fileNode.LinkPath;
191 m_CopyToOutputs[ fileNode.Path ] = fileNode.CopyToOutput; 191 m_CopyToOutputs[ fileNode.Path ] = fileNode.CopyToOutput;
192 192
193 } 193 }
194 } 194 }
195 } 195 }
196 else if(dataNode is MatchNode) 196 else if(dataNode is MatchNode)
197 { 197 {
198 foreach(string file in ((MatchNode)dataNode).Files) 198 foreach(string file in ((MatchNode)dataNode).Files)
199 { 199 {
200 MatchNode matchNode = (MatchNode)dataNode; 200 MatchNode matchNode = (MatchNode)dataNode;
201 if (!m_Files.Contains(file)) 201 if (!m_Files.Contains(file))
202 { 202 {
203 m_Files.Add(file); 203 m_Files.Add(file);
204 if (matchNode.BuildAction == null) 204 if (matchNode.BuildAction == null)
205 m_BuildActions[file] = GetBuildActionByFileName(file); 205 m_BuildActions[file] = GetBuildActionByFileName(file);
206 else 206 else
207 m_BuildActions[file] = matchNode.BuildAction.Value; 207 m_BuildActions[file] = matchNode.BuildAction.Value;
208 208
209 if (matchNode.BuildAction == BuildAction.Copy) 209 if (matchNode.BuildAction == BuildAction.Copy)
@@ -212,27 +212,27 @@ namespace Prebuild.Core.Nodes
212 m_DestinationPath[file] = matchNode.DestinationPath; 212 m_DestinationPath[file] = matchNode.DestinationPath;
213 } 213 }
214 214
215 m_SubTypes[file] = matchNode.SubType == null ? GetSubTypeByFileName(file) : matchNode.SubType.Value; 215 m_SubTypes[file] = matchNode.SubType == null ? GetSubTypeByFileName(file) : matchNode.SubType.Value;
216 m_ResourceNames[ file ] = matchNode.ResourceName; 216 m_ResourceNames[ file ] = matchNode.ResourceName;
217 m_PreservePaths[ file ] = matchNode.PreservePath; 217 m_PreservePaths[ file ] = matchNode.PreservePath;
218 m_Links[ file ] = matchNode.IsLink; 218 m_Links[ file ] = matchNode.IsLink;
219 m_LinkPaths[ file ] = matchNode.LinkPath; 219 m_LinkPaths[ file ] = matchNode.LinkPath;
220 m_CopyToOutputs[ file ] = matchNode.CopyToOutput; 220 m_CopyToOutputs[ file ] = matchNode.CopyToOutput;
221 221
222 } 222 }
223 } 223 }
224 } 224 }
225 } 225 }
226 } 226 }
227 227
228 // TODO: Check in to why StringCollection's enumerator doesn't implement 228 // TODO: Check in to why StringCollection's enumerator doesn't implement
229 // IEnumerator? 229 // IEnumerator?
230 public IEnumerator<string> GetEnumerator() 230 public IEnumerator<string> GetEnumerator()
231 { 231 {
232 return m_Files.GetEnumerator(); 232 return m_Files.GetEnumerator();
233 } 233 }
234 234
235 #endregion 235 #endregion
236 236
237 } 237 }
238} 238}