diff options
Diffstat (limited to 'Prebuild/src/Core/Nodes/FilesNode.cs')
-rw-r--r-- | Prebuild/src/Core/Nodes/FilesNode.cs | 121 |
1 files changed, 39 insertions, 82 deletions
diff --git a/Prebuild/src/Core/Nodes/FilesNode.cs b/Prebuild/src/Core/Nodes/FilesNode.cs index dc306c2..23a716c 100644 --- a/Prebuild/src/Core/Nodes/FilesNode.cs +++ b/Prebuild/src/Core/Nodes/FilesNode.cs | |||
@@ -24,8 +24,7 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O | |||
24 | #endregion | 24 | #endregion |
25 | 25 | ||
26 | using System; | 26 | using System; |
27 | using System.Collections; | 27 | using System.Collections.Generic; |
28 | using System.Collections.Specialized; | ||
29 | using System.Xml; | 28 | using System.Xml; |
30 | 29 | ||
31 | using Prebuild.Core.Attributes; | 30 | using Prebuild.Core.Attributes; |
@@ -42,41 +41,19 @@ namespace Prebuild.Core.Nodes | |||
42 | { | 41 | { |
43 | #region Fields | 42 | #region Fields |
44 | 43 | ||
45 | private StringCollection m_Files; | 44 | private readonly List<string> m_Files = new List<string>(); |
46 | private Hashtable m_BuildActions; | 45 | private readonly Dictionary<string,BuildAction> m_BuildActions = new Dictionary<string, BuildAction>(); |
47 | private Hashtable m_SubTypes; | 46 | private readonly Dictionary<string, SubType> m_SubTypes = new Dictionary<string, SubType>(); |
48 | private Hashtable m_ResourceNames; | 47 | private readonly Dictionary<string, string> m_ResourceNames = new Dictionary<string, string>(); |
49 | private Hashtable m_CopyToOutputs; | 48 | private readonly Dictionary<string, CopyToOutput> m_CopyToOutputs = new Dictionary<string, CopyToOutput>(); |
50 | private Hashtable m_Links; | 49 | private readonly Dictionary<string, bool> m_Links = new Dictionary<string, bool>(); |
51 | private Hashtable m_LinkPaths; | 50 | private readonly Dictionary<string, string> m_LinkPaths = new Dictionary<string, string>(); |
52 | private Hashtable m_PreservePaths; | 51 | private readonly Dictionary<string, bool> m_PreservePaths = new Dictionary<string, bool>(); |
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 | 52 | ||
73 | #endregion | 53 | #endregion |
74 | 54 | ||
75 | #region Properties | 55 | #region Properties |
76 | 56 | ||
77 | /// <summary> | ||
78 | /// | ||
79 | /// </summary> | ||
80 | public int Count | 57 | public int Count |
81 | { | 58 | { |
82 | get | 59 | get |
@@ -89,11 +66,6 @@ namespace Prebuild.Core.Nodes | |||
89 | 66 | ||
90 | #region Public Methods | 67 | #region Public Methods |
91 | 68 | ||
92 | /// <summary> | ||
93 | /// | ||
94 | /// </summary> | ||
95 | /// <param name="file"></param> | ||
96 | /// <returns></returns> | ||
97 | public BuildAction GetBuildAction(string file) | 69 | public BuildAction GetBuildAction(string file) |
98 | { | 70 | { |
99 | if(!m_BuildActions.ContainsKey(file)) | 71 | if(!m_BuildActions.ContainsKey(file)) |
@@ -101,41 +73,41 @@ namespace Prebuild.Core.Nodes | |||
101 | return BuildAction.Compile; | 73 | return BuildAction.Compile; |
102 | } | 74 | } |
103 | 75 | ||
104 | return (BuildAction)m_BuildActions[file]; | 76 | return m_BuildActions[file]; |
105 | } | 77 | } |
106 | 78 | ||
107 | public CopyToOutput GetCopyToOutput(string file) | 79 | public CopyToOutput GetCopyToOutput(string file) |
108 | { | 80 | { |
109 | if (!this.m_CopyToOutputs.ContainsKey(file)) | 81 | if (!m_CopyToOutputs.ContainsKey(file)) |
110 | { | 82 | { |
111 | return CopyToOutput.Never; | 83 | return CopyToOutput.Never; |
112 | } | 84 | } |
113 | return (CopyToOutput) this.m_CopyToOutputs[file]; | 85 | return m_CopyToOutputs[file]; |
114 | } | 86 | } |
115 | 87 | ||
116 | public bool GetIsLink(string file) | 88 | public bool GetIsLink(string file) |
117 | { | 89 | { |
118 | if (!this.m_Links.ContainsKey(file)) | 90 | if (!m_Links.ContainsKey(file)) |
119 | { | 91 | { |
120 | return false; | 92 | return false; |
121 | } | 93 | } |
122 | return (bool) this.m_Links[file]; | 94 | return m_Links[file]; |
123 | } | 95 | } |
124 | 96 | ||
97 | public bool Contains(string file) | ||
98 | { | ||
99 | return m_Files.Contains(file); | ||
100 | } | ||
101 | |||
125 | public string GetLinkPath( string file ) | 102 | public string GetLinkPath( string file ) |
126 | { | 103 | { |
127 | if ( !this.m_LinkPaths.ContainsKey( file ) ) | 104 | if ( !m_LinkPaths.ContainsKey( file ) ) |
128 | { | 105 | { |
129 | return string.Empty; | 106 | return string.Empty; |
130 | } | 107 | } |
131 | return (string)this.m_LinkPaths[ file ]; | 108 | return m_LinkPaths[ file ]; |
132 | } | 109 | } |
133 | 110 | ||
134 | /// <summary> | ||
135 | /// | ||
136 | /// </summary> | ||
137 | /// <param name="file"></param> | ||
138 | /// <returns></returns> | ||
139 | public SubType GetSubType(string file) | 111 | public SubType GetSubType(string file) |
140 | { | 112 | { |
141 | if(!m_SubTypes.ContainsKey(file)) | 113 | if(!m_SubTypes.ContainsKey(file)) |
@@ -143,29 +115,19 @@ namespace Prebuild.Core.Nodes | |||
143 | return SubType.Code; | 115 | return SubType.Code; |
144 | } | 116 | } |
145 | 117 | ||
146 | return (SubType)m_SubTypes[file]; | 118 | return m_SubTypes[file]; |
147 | } | 119 | } |
148 | 120 | ||
149 | /// <summary> | ||
150 | /// | ||
151 | /// </summary> | ||
152 | /// <param name="file"></param> | ||
153 | /// <returns></returns> | ||
154 | public string GetResourceName(string file) | 121 | public string GetResourceName(string file) |
155 | { | 122 | { |
156 | if(!m_ResourceNames.ContainsKey(file)) | 123 | if(!m_ResourceNames.ContainsKey(file)) |
157 | { | 124 | { |
158 | return ""; | 125 | return string.Empty; |
159 | } | 126 | } |
160 | 127 | ||
161 | return (string)m_ResourceNames[file]; | 128 | return m_ResourceNames[file]; |
162 | } | 129 | } |
163 | 130 | ||
164 | /// <summary> | ||
165 | /// | ||
166 | /// </summary> | ||
167 | /// <param name="file"></param> | ||
168 | /// <returns></returns> | ||
169 | public bool GetPreservePath( string file ) | 131 | public bool GetPreservePath( string file ) |
170 | { | 132 | { |
171 | if ( !m_PreservePaths.ContainsKey( file ) ) | 133 | if ( !m_PreservePaths.ContainsKey( file ) ) |
@@ -173,13 +135,9 @@ namespace Prebuild.Core.Nodes | |||
173 | return false; | 135 | return false; |
174 | } | 136 | } |
175 | 137 | ||
176 | return (bool)m_PreservePaths[ file ]; | 138 | return m_PreservePaths[ file ]; |
177 | } | 139 | } |
178 | 140 | ||
179 | /// <summary> | ||
180 | /// | ||
181 | /// </summary> | ||
182 | /// <param name="node"></param> | ||
183 | public override void Parse(XmlNode node) | 141 | public override void Parse(XmlNode node) |
184 | { | 142 | { |
185 | if( node == null ) | 143 | if( node == null ) |
@@ -200,10 +158,10 @@ namespace Prebuild.Core.Nodes | |||
200 | m_BuildActions[fileNode.Path] = fileNode.BuildAction; | 158 | m_BuildActions[fileNode.Path] = fileNode.BuildAction; |
201 | m_SubTypes[fileNode.Path] = fileNode.SubType; | 159 | m_SubTypes[fileNode.Path] = fileNode.SubType; |
202 | m_ResourceNames[fileNode.Path] = fileNode.ResourceName; | 160 | m_ResourceNames[fileNode.Path] = fileNode.ResourceName; |
203 | this.m_PreservePaths[ fileNode.Path ] = fileNode.PreservePath; | 161 | m_PreservePaths[ fileNode.Path ] = fileNode.PreservePath; |
204 | this.m_Links[ fileNode.Path ] = fileNode.IsLink; | 162 | m_Links[ fileNode.Path ] = fileNode.IsLink; |
205 | this.m_LinkPaths[ fileNode.Path ] = fileNode.LinkPath; | 163 | m_LinkPaths[ fileNode.Path ] = fileNode.LinkPath; |
206 | this.m_CopyToOutputs[ fileNode.Path ] = fileNode.CopyToOutput; | 164 | m_CopyToOutputs[ fileNode.Path ] = fileNode.CopyToOutput; |
207 | 165 | ||
208 | } | 166 | } |
209 | } | 167 | } |
@@ -216,13 +174,16 @@ namespace Prebuild.Core.Nodes | |||
216 | if (!m_Files.Contains(file)) | 174 | if (!m_Files.Contains(file)) |
217 | { | 175 | { |
218 | m_Files.Add(file); | 176 | m_Files.Add(file); |
219 | m_BuildActions[ file ] = matchNode.BuildAction == null ? GetBuildActionByFileName(file) : matchNode.BuildAction; | 177 | if (matchNode.BuildAction == null) |
220 | m_SubTypes[file] = matchNode.SubType == null ? GetSubTypeByFileName(file) : matchNode.SubType.Value; | 178 | m_BuildActions[file] = GetBuildActionByFileName(file); |
179 | else | ||
180 | m_BuildActions[file] = matchNode.BuildAction.Value; | ||
181 | m_SubTypes[file] = matchNode.SubType == null ? GetSubTypeByFileName(file) : matchNode.SubType.Value; | ||
221 | m_ResourceNames[ file ] = matchNode.ResourceName; | 182 | m_ResourceNames[ file ] = matchNode.ResourceName; |
222 | this.m_PreservePaths[ file ] = matchNode.PreservePath; | 183 | m_PreservePaths[ file ] = matchNode.PreservePath; |
223 | this.m_Links[ file ] = matchNode.IsLink; | 184 | m_Links[ file ] = matchNode.IsLink; |
224 | this.m_LinkPaths[ file ] = matchNode.LinkPath; | 185 | m_LinkPaths[ file ] = matchNode.LinkPath; |
225 | this.m_CopyToOutputs[ file ] = matchNode.CopyToOutput; | 186 | m_CopyToOutputs[ file ] = matchNode.CopyToOutput; |
226 | 187 | ||
227 | } | 188 | } |
228 | } | 189 | } |
@@ -232,11 +193,7 @@ namespace Prebuild.Core.Nodes | |||
232 | 193 | ||
233 | // TODO: Check in to why StringCollection's enumerator doesn't implement | 194 | // TODO: Check in to why StringCollection's enumerator doesn't implement |
234 | // IEnumerator? | 195 | // IEnumerator? |
235 | /// <summary> | 196 | public IEnumerator<string> GetEnumerator() |
236 | /// | ||
237 | /// </summary> | ||
238 | /// <returns></returns> | ||
239 | public StringEnumerator GetEnumerator() | ||
240 | { | 197 | { |
241 | return m_Files.GetEnumerator(); | 198 | return m_Files.GetEnumerator(); |
242 | } | 199 | } |