diff options
author | Melanie Thielker | 2017-01-05 19:07:37 +0000 |
---|---|---|
committer | Melanie Thielker | 2017-01-05 19:07:37 +0000 |
commit | b16abc8166c29585cb76cc55c3bdd76e5833cb4f (patch) | |
tree | 6a34f465a74b7a3a6dc00a3d7aa8dcc25ac3e3a5 /Prebuild/src/Core/Kernel.cs | |
parent | Make it possible to disable the bakes module in the way it is described in co... (diff) | |
download | opensim-SC-b16abc8166c29585cb76cc55c3bdd76e5833cb4f.zip opensim-SC-b16abc8166c29585cb76cc55c3bdd76e5833cb4f.tar.gz opensim-SC-b16abc8166c29585cb76cc55c3bdd76e5833cb4f.tar.bz2 opensim-SC-b16abc8166c29585cb76cc55c3bdd76e5833cb4f.tar.xz |
Massive tab and trailing space cleanup
Diffstat (limited to '')
-rw-r--r-- | Prebuild/src/Core/Kernel.cs | 1400 |
1 files changed, 700 insertions, 700 deletions
diff --git a/Prebuild/src/Core/Kernel.cs b/Prebuild/src/Core/Kernel.cs index 761962e..454ff8b 100644 --- a/Prebuild/src/Core/Kernel.cs +++ b/Prebuild/src/Core/Kernel.cs | |||
@@ -49,202 +49,202 @@ using Prebuild.Core.Interfaces; | |||
49 | using Prebuild.Core.Nodes; | 49 | using Prebuild.Core.Nodes; |
50 | using Prebuild.Core.Utilities; | 50 | using Prebuild.Core.Utilities; |
51 | 51 | ||
52 | namespace Prebuild.Core | 52 | namespace Prebuild.Core |
53 | { | 53 | { |
54 | /// <summary> | 54 | /// <summary> |
55 | /// | 55 | /// |
56 | /// </summary> | 56 | /// </summary> |
57 | public class Kernel : IDisposable | 57 | public class Kernel : IDisposable |
58 | { | 58 | { |
59 | #region Inner Classes | 59 | #region Inner Classes |
60 | 60 | ||
61 | private struct NodeEntry | 61 | private struct NodeEntry |
62 | { | 62 | { |
63 | public Type Type; | 63 | public Type Type; |
64 | public DataNodeAttribute Attribute; | 64 | public DataNodeAttribute Attribute; |
65 | } | 65 | } |
66 | 66 | ||
67 | #endregion | 67 | #endregion |
68 | 68 | ||
69 | #region Fields | 69 | #region Fields |
70 | 70 | ||
71 | private static readonly Kernel m_Instance = new Kernel(); | 71 | private static readonly Kernel m_Instance = new Kernel(); |
72 | 72 | ||
73 | /// <summary> | 73 | /// <summary> |
74 | /// This must match the version of the schema that is embeeded | 74 | /// This must match the version of the schema that is embeeded |
75 | /// </summary> | 75 | /// </summary> |
76 | private const string m_SchemaVersion = "1.10"; | 76 | private const string m_SchemaVersion = "1.10"; |
77 | private const string m_Schema = "prebuild-" + m_SchemaVersion + ".xsd"; | 77 | private const string m_Schema = "prebuild-" + m_SchemaVersion + ".xsd"; |
78 | private const string m_SchemaURI = "http://dnpb.sourceforge.net/schemas/" + m_Schema; | 78 | private const string m_SchemaURI = "http://dnpb.sourceforge.net/schemas/" + m_Schema; |
79 | bool disposed; | 79 | bool disposed; |
80 | private Version m_Version; | 80 | private Version m_Version; |
81 | private const string m_Revision = ""; | 81 | private const string m_Revision = ""; |
82 | private CommandLineCollection m_CommandLine; | 82 | private CommandLineCollection m_CommandLine; |
83 | private Log m_Log; | 83 | private Log m_Log; |
84 | private CurrentDirectory m_CurrentWorkingDirectory; | 84 | private CurrentDirectory m_CurrentWorkingDirectory; |
85 | private XmlSchemaCollection m_Schemas; | 85 | private XmlSchemaCollection m_Schemas; |
86 | 86 | ||
87 | private readonly Dictionary<string, ITarget> m_Targets = new Dictionary<string, ITarget>(); | 87 | private readonly Dictionary<string, ITarget> m_Targets = new Dictionary<string, ITarget>(); |
88 | private readonly Dictionary<string, NodeEntry> m_Nodes = new Dictionary<string, NodeEntry>(); | 88 | private readonly Dictionary<string, NodeEntry> m_Nodes = new Dictionary<string, NodeEntry>(); |
89 | 89 | ||
90 | readonly List<SolutionNode> m_Solutions = new List<SolutionNode>(); | 90 | readonly List<SolutionNode> m_Solutions = new List<SolutionNode>(); |
91 | string m_Target; | 91 | string m_Target; |
92 | string m_Clean; | 92 | string m_Clean; |
93 | string[] m_RemoveDirectories; | 93 | string[] m_RemoveDirectories; |
94 | XmlDocument m_CurrentDoc; | 94 | XmlDocument m_CurrentDoc; |
95 | bool m_PauseAfterFinish; | 95 | bool m_PauseAfterFinish; |
96 | string[] m_ProjectGroups; | 96 | string[] m_ProjectGroups; |
97 | 97 | ||
98 | #endregion | 98 | #endregion |
99 | 99 | ||
100 | #region Constructors | 100 | #region Constructors |
101 | 101 | ||
102 | private Kernel() | 102 | private Kernel() |
103 | { | 103 | { |
104 | } | 104 | } |
105 | 105 | ||
106 | #endregion | 106 | #endregion |
107 | 107 | ||
108 | #region Properties | 108 | #region Properties |
109 | 109 | ||
110 | /// <summary> | 110 | /// <summary> |
111 | /// Gets a value indicating whether [pause after finish]. | 111 | /// Gets a value indicating whether [pause after finish]. |
112 | /// </summary> | 112 | /// </summary> |
113 | /// <value><c>true</c> if [pause after finish]; otherwise, <c>false</c>.</value> | 113 | /// <value><c>true</c> if [pause after finish]; otherwise, <c>false</c>.</value> |
114 | public bool PauseAfterFinish | 114 | public bool PauseAfterFinish |
115 | { | 115 | { |
116 | get | 116 | get |
117 | { | 117 | { |
118 | return m_PauseAfterFinish; | 118 | return m_PauseAfterFinish; |
119 | } | 119 | } |
120 | } | 120 | } |
121 | 121 | ||
122 | /// <summary> | 122 | /// <summary> |
123 | /// Gets the instance. | 123 | /// Gets the instance. |
124 | /// </summary> | 124 | /// </summary> |
125 | /// <value>The instance.</value> | 125 | /// <value>The instance.</value> |
126 | public static Kernel Instance | 126 | public static Kernel Instance |
127 | { | 127 | { |
128 | get | 128 | get |
129 | { | 129 | { |
130 | return m_Instance; | 130 | return m_Instance; |
131 | } | 131 | } |
132 | } | 132 | } |
133 | 133 | ||
134 | /// <summary> | 134 | /// <summary> |
135 | /// Gets the version. | 135 | /// Gets the version. |
136 | /// </summary> | 136 | /// </summary> |
137 | /// <value>The version.</value> | 137 | /// <value>The version.</value> |
138 | public string Version | 138 | public string Version |
139 | { | 139 | { |
140 | get | 140 | get |
141 | { | 141 | { |
142 | return String.Format("{0}.{1}.{2}{3}", m_Version.Major, m_Version.Minor, m_Version.Build, m_Revision); | 142 | return String.Format("{0}.{1}.{2}{3}", m_Version.Major, m_Version.Minor, m_Version.Build, m_Revision); |
143 | } | 143 | } |
144 | } | 144 | } |
145 | 145 | ||
146 | /// <summary> | 146 | /// <summary> |
147 | /// Gets the command line. | 147 | /// Gets the command line. |
148 | /// </summary> | 148 | /// </summary> |
149 | /// <value>The command line.</value> | 149 | /// <value>The command line.</value> |
150 | public CommandLineCollection CommandLine | 150 | public CommandLineCollection CommandLine |
151 | { | 151 | { |
152 | get | 152 | get |
153 | { | 153 | { |
154 | return m_CommandLine; | 154 | return m_CommandLine; |
155 | } | 155 | } |
156 | } | 156 | } |
157 | 157 | ||
158 | /// <summary> | 158 | /// <summary> |
159 | /// Gets the targets. | 159 | /// Gets the targets. |
160 | /// </summary> | 160 | /// </summary> |
161 | /// <value>The targets.</value> | 161 | /// <value>The targets.</value> |
162 | public Dictionary<string, ITarget> Targets | 162 | public Dictionary<string, ITarget> Targets |
163 | { | 163 | { |
164 | get | 164 | get |
165 | { | 165 | { |
166 | return m_Targets; | 166 | return m_Targets; |
167 | } | 167 | } |
168 | } | 168 | } |
169 | 169 | ||
170 | /// <summary> | 170 | /// <summary> |
171 | /// Gets the log. | 171 | /// Gets the log. |
172 | /// </summary> | 172 | /// </summary> |
173 | /// <value>The log.</value> | 173 | /// <value>The log.</value> |
174 | public Log Log | 174 | public Log Log |
175 | { | 175 | { |
176 | get | 176 | get |
177 | { | 177 | { |
178 | return m_Log; | 178 | return m_Log; |
179 | } | 179 | } |
180 | } | 180 | } |
181 | 181 | ||
182 | /// <summary> | 182 | /// <summary> |
183 | /// Gets the current working directory. | 183 | /// Gets the current working directory. |
184 | /// </summary> | 184 | /// </summary> |
185 | /// <value>The current working directory.</value> | 185 | /// <value>The current working directory.</value> |
186 | public CurrentDirectory CurrentWorkingDirectory | 186 | public CurrentDirectory CurrentWorkingDirectory |
187 | { | 187 | { |
188 | get | 188 | get |
189 | { | 189 | { |
190 | return m_CurrentWorkingDirectory; | 190 | return m_CurrentWorkingDirectory; |
191 | } | 191 | } |
192 | } | 192 | } |
193 | 193 | ||
194 | /// <summary> | 194 | /// <summary> |
195 | /// Gets the solutions. | 195 | /// Gets the solutions. |
196 | /// </summary> | 196 | /// </summary> |
197 | /// <value>The solutions.</value> | 197 | /// <value>The solutions.</value> |
198 | public List<SolutionNode> Solutions | 198 | public List<SolutionNode> Solutions |
199 | { | 199 | { |
200 | get | 200 | get |
201 | { | 201 | { |
202 | return m_Solutions; | 202 | return m_Solutions; |
203 | } | 203 | } |
204 | } | 204 | } |
205 | 205 | ||
206 | /// <summary> | 206 | /// <summary> |
207 | /// Gets the XmlDocument object representing the prebuild.xml | 207 | /// Gets the XmlDocument object representing the prebuild.xml |
208 | /// being processed | 208 | /// being processed |
209 | /// </summary> | 209 | /// </summary> |
210 | /// <value>The XmlDocument object</value> | 210 | /// <value>The XmlDocument object</value> |
211 | public XmlDocument CurrentDoc | 211 | public XmlDocument CurrentDoc |
212 | { | 212 | { |
213 | get | 213 | get |
214 | { | 214 | { |
215 | return m_CurrentDoc; | 215 | return m_CurrentDoc; |
216 | } | 216 | } |
217 | } | 217 | } |
218 | 218 | ||
219 | #endregion | 219 | #endregion |
220 | 220 | ||
221 | #region Private Methods | 221 | #region Private Methods |
222 | 222 | ||
223 | private static void RemoveDirectories(string rootDir, string[] dirNames) | 223 | private static void RemoveDirectories(string rootDir, string[] dirNames) |
224 | { | 224 | { |
225 | foreach(string dir in Directory.GetDirectories(rootDir)) | 225 | foreach(string dir in Directory.GetDirectories(rootDir)) |
226 | { | 226 | { |
227 | string simpleName = Path.GetFileName(dir); | 227 | string simpleName = Path.GetFileName(dir); |
228 | 228 | ||
229 | if(Array.IndexOf(dirNames, simpleName) != -1) | 229 | if(Array.IndexOf(dirNames, simpleName) != -1) |
230 | { | 230 | { |
231 | //delete if the name matches one of the directory names to delete | 231 | //delete if the name matches one of the directory names to delete |
232 | string fullDirPath = Path.GetFullPath(dir); | 232 | string fullDirPath = Path.GetFullPath(dir); |
233 | Directory.Delete(fullDirPath,true); | 233 | Directory.Delete(fullDirPath,true); |
234 | } | 234 | } |
235 | else//not a match, so check children | 235 | else//not a match, so check children |
236 | { | 236 | { |
237 | RemoveDirectories(dir,dirNames); | 237 | RemoveDirectories(dir,dirNames); |
238 | //recurse, checking children for them | 238 | //recurse, checking children for them |
239 | } | 239 | } |
240 | } | 240 | } |
241 | } | 241 | } |
242 | 242 | ||
243 | // private void RemoveDirectoryMatches(string rootDir, string dirPattern) | 243 | // private void RemoveDirectoryMatches(string rootDir, string dirPattern) |
244 | // { | 244 | // { |
245 | // foreach(string dir in Directory.GetDirectories(rootDir)) | 245 | // foreach(string dir in Directory.GetDirectories(rootDir)) |
246 | // { | 246 | // { |
247 | // foreach(string match in Directory.GetDirectories(dir)) | 247 | // foreach(string match in Directory.GetDirectories(dir)) |
248 | // {//delete all child directories that match | 248 | // {//delete all child directories that match |
249 | // Directory.Delete(Path.GetFullPath(match),true); | 249 | // Directory.Delete(Path.GetFullPath(match),true); |
250 | // } | 250 | // } |
@@ -253,56 +253,56 @@ namespace Prebuild.Core | |||
253 | // } | 253 | // } |
254 | // } | 254 | // } |
255 | 255 | ||
256 | private void LoadSchema() | 256 | private void LoadSchema() |
257 | { | 257 | { |
258 | Assembly assembly = GetType().Assembly; | 258 | Assembly assembly = GetType().Assembly; |
259 | Stream stream = assembly.GetManifestResourceStream("Prebuild.data." + m_Schema); | 259 | Stream stream = assembly.GetManifestResourceStream("Prebuild.data." + m_Schema); |
260 | if(stream == null) | 260 | if(stream == null) |
261 | { | 261 | { |
262 | //try without the default namespace prepending to it in case was compiled with SharpDevelop or MonoDevelop instead of Visual Studio .NET | 262 | //try without the default namespace prepending to it in case was compiled with SharpDevelop or MonoDevelop instead of Visual Studio .NET |
263 | stream = assembly.GetManifestResourceStream(m_Schema); | 263 | stream = assembly.GetManifestResourceStream(m_Schema); |
264 | if(stream == null) | 264 | if(stream == null) |
265 | { | 265 | { |
266 | throw new System.Reflection.TargetException(string.Format("Could not find the scheme embedded resource file '{0}'.", m_Schema)); | 266 | throw new System.Reflection.TargetException(string.Format("Could not find the scheme embedded resource file '{0}'.", m_Schema)); |
267 | } | 267 | } |
268 | } | 268 | } |
269 | XmlReader schema = new XmlTextReader(stream); | 269 | XmlReader schema = new XmlTextReader(stream); |
270 | 270 | ||
271 | m_Schemas = new XmlSchemaCollection(); | 271 | m_Schemas = new XmlSchemaCollection(); |
272 | m_Schemas.Add(m_SchemaURI, schema); | 272 | m_Schemas.Add(m_SchemaURI, schema); |
273 | } | 273 | } |
274 | 274 | ||
275 | private void CacheVersion() | 275 | private void CacheVersion() |
276 | { | 276 | { |
277 | m_Version = Assembly.GetEntryAssembly().GetName().Version; | 277 | m_Version = Assembly.GetEntryAssembly().GetName().Version; |
278 | } | 278 | } |
279 | 279 | ||
280 | private void CacheTargets(Assembly assm) | 280 | private void CacheTargets(Assembly assm) |
281 | { | 281 | { |
282 | foreach(Type t in assm.GetTypes()) | 282 | foreach(Type t in assm.GetTypes()) |
283 | { | 283 | { |
284 | TargetAttribute ta = (TargetAttribute)Helper.CheckType(t, typeof(TargetAttribute), typeof(ITarget)); | 284 | TargetAttribute ta = (TargetAttribute)Helper.CheckType(t, typeof(TargetAttribute), typeof(ITarget)); |
285 | 285 | ||
286 | if(ta == null) | 286 | if(ta == null) |
287 | continue; | 287 | continue; |
288 | 288 | ||
289 | if (t.IsAbstract) | 289 | if (t.IsAbstract) |
290 | continue; | 290 | continue; |
291 | 291 | ||
292 | ITarget target = (ITarget)assm.CreateInstance(t.FullName); | 292 | ITarget target = (ITarget)assm.CreateInstance(t.FullName); |
293 | if (target == null) | 293 | if (target == null) |
294 | { | 294 | { |
295 | throw new MissingMethodException("Could not create ITarget instance"); | 295 | throw new MissingMethodException("Could not create ITarget instance"); |
296 | } | 296 | } |
297 | 297 | ||
298 | m_Targets[ta.Name] = target; | 298 | m_Targets[ta.Name] = target; |
299 | } | 299 | } |
300 | } | 300 | } |
301 | 301 | ||
302 | private void CacheNodeTypes(Assembly assm) | 302 | private void CacheNodeTypes(Assembly assm) |
303 | { | 303 | { |
304 | foreach(Type t in assm.GetTypes()) | 304 | foreach(Type t in assm.GetTypes()) |
305 | { | 305 | { |
306 | foreach (DataNodeAttribute dna in t.GetCustomAttributes(typeof(DataNodeAttribute), true)) | 306 | foreach (DataNodeAttribute dna in t.GetCustomAttributes(typeof(DataNodeAttribute), true)) |
307 | { | 307 | { |
308 | NodeEntry ne = new NodeEntry(); | 308 | NodeEntry ne = new NodeEntry(); |
@@ -310,11 +310,11 @@ namespace Prebuild.Core | |||
310 | ne.Attribute = dna; | 310 | ne.Attribute = dna; |
311 | m_Nodes[dna.Name] = ne; | 311 | m_Nodes[dna.Name] = ne; |
312 | } | 312 | } |
313 | } | 313 | } |
314 | } | 314 | } |
315 | 315 | ||
316 | private void LogBanner() | 316 | private void LogBanner() |
317 | { | 317 | { |
318 | m_Log.Write("Prebuild v" + Version); | 318 | m_Log.Write("Prebuild v" + Version); |
319 | m_Log.Write("Copyright (c) 2004-2010"); | 319 | m_Log.Write("Copyright (c) 2004-2010"); |
320 | m_Log.Write("Matthew Holmes (matthew@wildfiregames.com),"); | 320 | m_Log.Write("Matthew Holmes (matthew@wildfiregames.com),"); |
@@ -326,7 +326,7 @@ namespace Prebuild.Core | |||
326 | 326 | ||
327 | m_Log.Write("See 'prebuild /usage' for help"); | 327 | m_Log.Write("See 'prebuild /usage' for help"); |
328 | m_Log.Write(); | 328 | m_Log.Write(); |
329 | } | 329 | } |
330 | 330 | ||
331 | 331 | ||
332 | 332 | ||
@@ -348,37 +348,37 @@ namespace Prebuild.Core | |||
348 | } | 348 | } |
349 | 349 | ||
350 | /// <summary> | 350 | /// <summary> |
351 | /// | 351 | /// |
352 | /// </summary> | 352 | /// </summary> |
353 | /// <param name="file"></param> | 353 | /// <param name="file"></param> |
354 | /// <param name="solutions"></param> | 354 | /// <param name="solutions"></param> |
355 | /// <returns></returns> | 355 | /// <returns></returns> |
356 | public void ProcessFile(string file, IList<SolutionNode> solutions) | 356 | public void ProcessFile(string file, IList<SolutionNode> solutions) |
357 | { | 357 | { |
358 | m_CurrentWorkingDirectory.Push(); | 358 | m_CurrentWorkingDirectory.Push(); |
359 | 359 | ||
360 | string path = file; | 360 | string path = file; |
361 | try | 361 | try |
362 | { | 362 | { |
363 | try | 363 | try |
364 | { | 364 | { |
365 | path = Helper.ResolvePath(path); | 365 | path = Helper.ResolvePath(path); |
366 | } | 366 | } |
367 | catch(ArgumentException) | 367 | catch(ArgumentException) |
368 | { | 368 | { |
369 | m_Log.Write("Could not open Prebuild file: " + path); | 369 | m_Log.Write("Could not open Prebuild file: " + path); |
370 | m_CurrentWorkingDirectory.Pop(); | 370 | m_CurrentWorkingDirectory.Pop(); |
371 | return; | 371 | return; |
372 | } | 372 | } |
373 | 373 | ||
374 | Helper.SetCurrentDir(Path.GetDirectoryName(path)); | 374 | Helper.SetCurrentDir(Path.GetDirectoryName(path)); |
375 | 375 | ||
376 | XmlTextReader reader = new XmlTextReader(path); | 376 | XmlTextReader reader = new XmlTextReader(path); |
377 | 377 | ||
378 | Core.Parse.Preprocessor pre = new Core.Parse.Preprocessor(); | 378 | Core.Parse.Preprocessor pre = new Core.Parse.Preprocessor(); |
379 | 379 | ||
380 | //register command line arguments as XML variables | 380 | //register command line arguments as XML variables |
381 | IEnumerator<KeyValuePair<string, string>> dict = m_CommandLine.GetEnumerator(); | 381 | IEnumerator<KeyValuePair<string, string>> dict = m_CommandLine.GetEnumerator(); |
382 | while (dict.MoveNext()) | 382 | while (dict.MoveNext()) |
383 | { | 383 | { |
384 | string name = dict.Current.Key.Trim(); | 384 | string name = dict.Current.Key.Trim(); |
@@ -386,447 +386,447 @@ namespace Prebuild.Core | |||
386 | pre.RegisterVariable(name, dict.Current.Value); | 386 | pre.RegisterVariable(name, dict.Current.Value); |
387 | } | 387 | } |
388 | 388 | ||
389 | string xml = pre.Process(reader);//remove script and evaulate pre-proccessing to get schema-conforming XML | 389 | string xml = pre.Process(reader);//remove script and evaulate pre-proccessing to get schema-conforming XML |
390 | 390 | ||
391 | // See if the user put into a pseudo target of "prebuild:preprocessed-input" to indicate they want to see the | 391 | // See if the user put into a pseudo target of "prebuild:preprocessed-input" to indicate they want to see the |
392 | // output before the system processes it. | 392 | // output before the system processes it. |
393 | if (m_CommandLine.WasPassed("ppi")) | 393 | if (m_CommandLine.WasPassed("ppi")) |
394 | { | 394 | { |
395 | // Get the filename if there is one, otherwise use a default. | 395 | // Get the filename if there is one, otherwise use a default. |
396 | string ppiFile = m_CommandLine["ppi"]; | 396 | string ppiFile = m_CommandLine["ppi"]; |
397 | if (ppiFile == null || ppiFile.Trim().Length == 0) | 397 | if (ppiFile == null || ppiFile.Trim().Length == 0) |
398 | { | 398 | { |
399 | ppiFile = "preprocessed-input.xml"; | 399 | ppiFile = "preprocessed-input.xml"; |
400 | } | 400 | } |
401 | 401 | ||
402 | // Write out the string to the given stream. | 402 | // Write out the string to the given stream. |
403 | try | 403 | try |
404 | { | 404 | { |
405 | using (StreamWriter ppiWriter = new StreamWriter(ppiFile)) | 405 | using (StreamWriter ppiWriter = new StreamWriter(ppiFile)) |
406 | { | 406 | { |
407 | ppiWriter.WriteLine(xml); | 407 | ppiWriter.WriteLine(xml); |
408 | } | 408 | } |
409 | } | 409 | } |
410 | catch(IOException ex) | 410 | catch(IOException ex) |
411 | { | 411 | { |
412 | Console.WriteLine("Could not write PPI file '{0}': {1}", ppiFile, ex.Message); | 412 | Console.WriteLine("Could not write PPI file '{0}': {1}", ppiFile, ex.Message); |
413 | } | 413 | } |
414 | 414 | ||
415 | // Finish processing this special tag. | 415 | // Finish processing this special tag. |
416 | return; | 416 | return; |
417 | } | 417 | } |
418 | 418 | ||
419 | m_CurrentDoc = new XmlDocument(); | 419 | m_CurrentDoc = new XmlDocument(); |
420 | try | 420 | try |
421 | { | 421 | { |
422 | #if NO_VALIDATE | 422 | #if NO_VALIDATE |
423 | XmlReader validator = XmlReader.Create(new StringReader(xml)); | 423 | XmlReader validator = XmlReader.Create(new StringReader(xml)); |
424 | m_CurrentDoc.Load(validator); | 424 | m_CurrentDoc.Load(validator); |
425 | #else | 425 | #else |
426 | XmlValidatingReader validator = new XmlValidatingReader(new XmlTextReader(new StringReader(xml))); | 426 | XmlValidatingReader validator = new XmlValidatingReader(new XmlTextReader(new StringReader(xml))); |
427 | 427 | ||
428 | //validate while reading from string into XmlDocument DOM structure in memory | 428 | //validate while reading from string into XmlDocument DOM structure in memory |
429 | foreach(XmlSchema schema in m_Schemas) | 429 | foreach(XmlSchema schema in m_Schemas) |
430 | { | 430 | { |
431 | validator.Schemas.Add(schema); | 431 | validator.Schemas.Add(schema); |
432 | } | 432 | } |
433 | m_CurrentDoc.Load(validator); | 433 | m_CurrentDoc.Load(validator); |
434 | #endif | 434 | #endif |
435 | } | 435 | } |
436 | catch(XmlException e) | 436 | catch(XmlException e) |
437 | { | 437 | { |
438 | throw new XmlException(e.ToString()); | 438 | throw new XmlException(e.ToString()); |
439 | } | 439 | } |
440 | 440 | ||
441 | //is there a purpose to writing it? An syntax/schema problem would have been found during pre.Process() and reported with details | 441 | //is there a purpose to writing it? An syntax/schema problem would have been found during pre.Process() and reported with details |
442 | if(m_CommandLine.WasPassed("ppo")) | 442 | if(m_CommandLine.WasPassed("ppo")) |
443 | { | 443 | { |
444 | string ppoFile = m_CommandLine["ppo"]; | 444 | string ppoFile = m_CommandLine["ppo"]; |
445 | if(ppoFile == null || ppoFile.Trim().Length < 1) | 445 | if(ppoFile == null || ppoFile.Trim().Length < 1) |
446 | { | 446 | { |
447 | ppoFile = "preprocessed.xml"; | 447 | ppoFile = "preprocessed.xml"; |
448 | } | 448 | } |
449 | 449 | ||
450 | StreamWriter writer = null; | 450 | StreamWriter writer = null; |
451 | try | 451 | try |
452 | { | 452 | { |
453 | writer = new StreamWriter(ppoFile); | 453 | writer = new StreamWriter(ppoFile); |
454 | writer.Write(xml); | 454 | writer.Write(xml); |
455 | } | 455 | } |
456 | catch(IOException ex) | 456 | catch(IOException ex) |
457 | { | 457 | { |
458 | Console.WriteLine("Could not write PPO file '{0}': {1}", ppoFile, ex.Message); | 458 | Console.WriteLine("Could not write PPO file '{0}': {1}", ppoFile, ex.Message); |
459 | } | 459 | } |
460 | finally | 460 | finally |
461 | { | 461 | { |
462 | if(writer != null) | 462 | if(writer != null) |
463 | { | 463 | { |
464 | writer.Close(); | 464 | writer.Close(); |
465 | } | 465 | } |
466 | } | 466 | } |
467 | return; | 467 | return; |
468 | } | 468 | } |
469 | //start reading the xml config file | 469 | //start reading the xml config file |
470 | XmlElement rootNode = m_CurrentDoc.DocumentElement; | 470 | XmlElement rootNode = m_CurrentDoc.DocumentElement; |
471 | //string suggestedVersion = Helper.AttributeValue(rootNode,"version","1.0"); | 471 | //string suggestedVersion = Helper.AttributeValue(rootNode,"version","1.0"); |
472 | Helper.CheckForOSVariables = Helper.ParseBoolean(rootNode,"checkOsVars",false); | 472 | Helper.CheckForOSVariables = Helper.ParseBoolean(rootNode,"checkOsVars",false); |
473 | 473 | ||
474 | foreach(XmlNode node in rootNode.ChildNodes)//solutions or if pre-proc instructions | 474 | foreach(XmlNode node in rootNode.ChildNodes)//solutions or if pre-proc instructions |
475 | { | 475 | { |
476 | IDataNode dataNode = ParseNode(node, null); | 476 | IDataNode dataNode = ParseNode(node, null); |
477 | if(dataNode is ProcessNode) | 477 | if(dataNode is ProcessNode) |
478 | { | 478 | { |
479 | ProcessNode proc = (ProcessNode)dataNode; | 479 | ProcessNode proc = (ProcessNode)dataNode; |
480 | if(proc.IsValid) | 480 | if(proc.IsValid) |
481 | { | 481 | { |
482 | ProcessFile(proc.Path); | 482 | ProcessFile(proc.Path); |
483 | } | 483 | } |
484 | } | 484 | } |
485 | else if(dataNode is SolutionNode) | 485 | else if(dataNode is SolutionNode) |
486 | { | 486 | { |
487 | solutions.Add((SolutionNode)dataNode); | 487 | solutions.Add((SolutionNode)dataNode); |
488 | } | 488 | } |
489 | } | 489 | } |
490 | } | 490 | } |
491 | catch(XmlSchemaException xse) | 491 | catch(XmlSchemaException xse) |
492 | { | 492 | { |
493 | m_Log.Write("XML validation error at line {0} in {1}:\n\n{2}", | 493 | m_Log.Write("XML validation error at line {0} in {1}:\n\n{2}", |
494 | xse.LineNumber, path, xse.Message); | 494 | xse.LineNumber, path, xse.Message); |
495 | } | 495 | } |
496 | finally | 496 | finally |
497 | { | 497 | { |
498 | m_CurrentWorkingDirectory.Pop(); | 498 | m_CurrentWorkingDirectory.Pop(); |
499 | } | 499 | } |
500 | } | 500 | } |
501 | 501 | ||
502 | #endregion | 502 | #endregion |
503 | 503 | ||
504 | #region Public Methods | 504 | #region Public Methods |
505 | 505 | ||
506 | /// <summary> | 506 | /// <summary> |
507 | /// Allows the project. | 507 | /// Allows the project. |
508 | /// </summary> | 508 | /// </summary> |
509 | /// <param name="projectGroupsFlags">The project groups flags.</param> | 509 | /// <param name="projectGroupsFlags">The project groups flags.</param> |
510 | /// <returns></returns> | 510 | /// <returns></returns> |
511 | public bool AllowProject(string projectGroupsFlags) | 511 | public bool AllowProject(string projectGroupsFlags) |
512 | { | 512 | { |
513 | if(m_ProjectGroups != null && m_ProjectGroups.Length > 0) | 513 | if(m_ProjectGroups != null && m_ProjectGroups.Length > 0) |
514 | { | 514 | { |
515 | if(projectGroupsFlags != null && projectGroupsFlags.Length == 0) | 515 | if(projectGroupsFlags != null && projectGroupsFlags.Length == 0) |
516 | { | 516 | { |
517 | foreach(string group in projectGroupsFlags.Split('|')) | 517 | foreach(string group in projectGroupsFlags.Split('|')) |
518 | { | 518 | { |
519 | if(Array.IndexOf(m_ProjectGroups, group) != -1) //if included in the filter list | 519 | if(Array.IndexOf(m_ProjectGroups, group) != -1) //if included in the filter list |
520 | { | 520 | { |
521 | return true; | 521 | return true; |
522 | } | 522 | } |
523 | } | 523 | } |
524 | } | 524 | } |
525 | return false;//not included in the list or no groups specified for the project | 525 | return false;//not included in the list or no groups specified for the project |
526 | } | 526 | } |
527 | return true;//no filter specified in the command line args | 527 | return true;//no filter specified in the command line args |
528 | } | 528 | } |
529 | 529 | ||
530 | /// <summary> | 530 | /// <summary> |
531 | /// Gets the type of the node. | 531 | /// Gets the type of the node. |
532 | /// </summary> | 532 | /// </summary> |
533 | /// <param name="node">The node.</param> | 533 | /// <param name="node">The node.</param> |
534 | /// <returns></returns> | 534 | /// <returns></returns> |
535 | public Type GetNodeType(XmlNode node) | 535 | public Type GetNodeType(XmlNode node) |
536 | { | 536 | { |
537 | if( node == null ) | 537 | if( node == null ) |
538 | { | 538 | { |
539 | throw new ArgumentNullException("node"); | 539 | throw new ArgumentNullException("node"); |
540 | } | 540 | } |
541 | if(!m_Nodes.ContainsKey(node.Name)) | 541 | if(!m_Nodes.ContainsKey(node.Name)) |
542 | { | 542 | { |
543 | return null; | 543 | return null; |
544 | } | 544 | } |
545 | 545 | ||
546 | NodeEntry ne = m_Nodes[node.Name]; | 546 | NodeEntry ne = m_Nodes[node.Name]; |
547 | return ne.Type; | 547 | return ne.Type; |
548 | } | 548 | } |
549 | 549 | ||
550 | /// <summary> | 550 | /// <summary> |
551 | /// | 551 | /// |
552 | /// </summary> | 552 | /// </summary> |
553 | /// <param name="node"></param> | 553 | /// <param name="node"></param> |
554 | /// <param name="parent"></param> | 554 | /// <param name="parent"></param> |
555 | /// <returns></returns> | 555 | /// <returns></returns> |
556 | public IDataNode ParseNode(XmlNode node, IDataNode parent) | 556 | public IDataNode ParseNode(XmlNode node, IDataNode parent) |
557 | { | 557 | { |
558 | return ParseNode(node, parent, null); | 558 | return ParseNode(node, parent, null); |
559 | } | 559 | } |
560 | 560 | ||
561 | //Create an instance of the data node type that is mapped to the name of the xml DOM node | 561 | //Create an instance of the data node type that is mapped to the name of the xml DOM node |
562 | /// <summary> | 562 | /// <summary> |
563 | /// Parses the node. | 563 | /// Parses the node. |
564 | /// </summary> | 564 | /// </summary> |
565 | /// <param name="node">The node.</param> | 565 | /// <param name="node">The node.</param> |
566 | /// <param name="parent">The parent.</param> | 566 | /// <param name="parent">The parent.</param> |
567 | /// <param name="preNode">The pre node.</param> | 567 | /// <param name="preNode">The pre node.</param> |
568 | /// <returns></returns> | 568 | /// <returns></returns> |
569 | public IDataNode ParseNode(XmlNode node, IDataNode parent, IDataNode preNode) | 569 | public IDataNode ParseNode(XmlNode node, IDataNode parent, IDataNode preNode) |
570 | { | 570 | { |
571 | IDataNode dataNode; | 571 | IDataNode dataNode; |
572 | 572 | ||
573 | try | 573 | try |
574 | { | 574 | { |
575 | if( node == null ) | 575 | if( node == null ) |
576 | { | 576 | { |
577 | throw new ArgumentNullException("node"); | 577 | throw new ArgumentNullException("node"); |
578 | } | 578 | } |
579 | if(preNode == null) | 579 | if(preNode == null) |
580 | { | 580 | { |
581 | if(!m_Nodes.ContainsKey(node.Name)) | 581 | if(!m_Nodes.ContainsKey(node.Name)) |
582 | { | 582 | { |
583 | Console.WriteLine("WARNING: Unknown XML node: " + node.Name); | 583 | Console.WriteLine("WARNING: Unknown XML node: " + node.Name); |
584 | return null; | 584 | return null; |
585 | } | 585 | } |
586 | 586 | ||
587 | NodeEntry ne = m_Nodes[node.Name]; | 587 | NodeEntry ne = m_Nodes[node.Name]; |
588 | Type type = ne.Type; | 588 | Type type = ne.Type; |
589 | //DataNodeAttribute dna = ne.Attribute; | 589 | //DataNodeAttribute dna = ne.Attribute; |
590 | 590 | ||
591 | dataNode = (IDataNode)type.Assembly.CreateInstance(type.FullName); | 591 | dataNode = (IDataNode)type.Assembly.CreateInstance(type.FullName); |
592 | if(dataNode == null) | 592 | if(dataNode == null) |
593 | { | 593 | { |
594 | throw new System.Reflection.TargetException("Could not create new parser instance: " + type.FullName); | 594 | throw new System.Reflection.TargetException("Could not create new parser instance: " + type.FullName); |
595 | } | 595 | } |
596 | } | 596 | } |
597 | else | 597 | else |
598 | dataNode = preNode; | 598 | dataNode = preNode; |
599 | 599 | ||
600 | dataNode.Parent = parent; | 600 | dataNode.Parent = parent; |
601 | dataNode.Parse(node); | 601 | dataNode.Parse(node); |
602 | } | 602 | } |
603 | catch(WarningException wex) | 603 | catch(WarningException wex) |
604 | { | 604 | { |
605 | m_Log.Write(LogType.Warning, wex.Message); | 605 | m_Log.Write(LogType.Warning, wex.Message); |
606 | return null; | 606 | return null; |
607 | } | 607 | } |
608 | catch(FatalException fex) | 608 | catch(FatalException fex) |
609 | { | 609 | { |
610 | m_Log.WriteException(LogType.Error, fex); | 610 | m_Log.WriteException(LogType.Error, fex); |
611 | throw; | 611 | throw; |
612 | } | 612 | } |
613 | catch(Exception ex) | 613 | catch(Exception ex) |
614 | { | 614 | { |
615 | m_Log.WriteException(LogType.Error, ex); | 615 | m_Log.WriteException(LogType.Error, ex); |
616 | throw; | 616 | throw; |
617 | } | 617 | } |
618 | 618 | ||
619 | return dataNode; | 619 | return dataNode; |
620 | } | 620 | } |
621 | 621 | ||
622 | /// <summary> | 622 | /// <summary> |
623 | /// Initializes the specified target. | 623 | /// Initializes the specified target. |
624 | /// </summary> | 624 | /// </summary> |
625 | /// <param name="target">The target.</param> | 625 | /// <param name="target">The target.</param> |
626 | /// <param name="args">The args.</param> | 626 | /// <param name="args">The args.</param> |
627 | public void Initialize(LogTargets target, string[] args) | 627 | public void Initialize(LogTargets target, string[] args) |
628 | { | 628 | { |
629 | CacheTargets(GetType().Assembly); | 629 | CacheTargets(GetType().Assembly); |
630 | CacheNodeTypes(GetType().Assembly); | 630 | CacheNodeTypes(GetType().Assembly); |
631 | CacheVersion(); | 631 | CacheVersion(); |
632 | 632 | ||
633 | m_CommandLine = new CommandLineCollection(args); | 633 | m_CommandLine = new CommandLineCollection(args); |
634 | 634 | ||
635 | string logFile = null; | 635 | string logFile = null; |
636 | if(m_CommandLine.WasPassed("log")) | 636 | if(m_CommandLine.WasPassed("log")) |
637 | { | 637 | { |
638 | logFile = m_CommandLine["log"]; | 638 | logFile = m_CommandLine["log"]; |
639 | 639 | ||
640 | if(logFile != null && logFile.Length == 0) | 640 | if(logFile != null && logFile.Length == 0) |
641 | { | 641 | { |
642 | logFile = "Prebuild.log"; | 642 | logFile = "Prebuild.log"; |
643 | } | 643 | } |
644 | } | 644 | } |
645 | else | 645 | else |
646 | { | 646 | { |
647 | target = target & ~LogTargets.File; //dont output to a file | 647 | target = target & ~LogTargets.File; //dont output to a file |
648 | } | 648 | } |
649 | 649 | ||
650 | m_Log = new Log(target, logFile); | 650 | m_Log = new Log(target, logFile); |
651 | LogBanner(); | 651 | LogBanner(); |
652 | 652 | ||
653 | m_CurrentWorkingDirectory = new CurrentDirectory(); | 653 | m_CurrentWorkingDirectory = new CurrentDirectory(); |
654 | 654 | ||
655 | m_Target = m_CommandLine["target"]; | 655 | m_Target = m_CommandLine["target"]; |
656 | m_Clean = m_CommandLine["clean"]; | 656 | m_Clean = m_CommandLine["clean"]; |
657 | string removeDirs = m_CommandLine["removedir"]; | 657 | string removeDirs = m_CommandLine["removedir"]; |
658 | if(removeDirs != null && removeDirs.Length == 0) | 658 | if(removeDirs != null && removeDirs.Length == 0) |
659 | { | 659 | { |
660 | m_RemoveDirectories = removeDirs.Split('|'); | 660 | m_RemoveDirectories = removeDirs.Split('|'); |
661 | } | 661 | } |
662 | 662 | ||
663 | string flags = m_CommandLine["allowedgroups"];//allows filtering by specifying a pipe-delimited list of groups to include | 663 | string flags = m_CommandLine["allowedgroups"];//allows filtering by specifying a pipe-delimited list of groups to include |
664 | if(flags != null && flags.Length == 0) | 664 | if(flags != null && flags.Length == 0) |
665 | { | 665 | { |
666 | m_ProjectGroups = flags.Split('|'); | 666 | m_ProjectGroups = flags.Split('|'); |
667 | } | 667 | } |
668 | m_PauseAfterFinish = m_CommandLine.WasPassed("pause"); | 668 | m_PauseAfterFinish = m_CommandLine.WasPassed("pause"); |
669 | 669 | ||
670 | LoadSchema(); | 670 | LoadSchema(); |
671 | } | 671 | } |
672 | 672 | ||
673 | /// <summary> | 673 | /// <summary> |
674 | /// Processes this instance. | 674 | /// Processes this instance. |
675 | /// </summary> | 675 | /// </summary> |
676 | public void Process() | 676 | public void Process() |
677 | { | 677 | { |
678 | bool perfomedOtherTask = false; | 678 | bool perfomedOtherTask = false; |
679 | if(m_RemoveDirectories != null && m_RemoveDirectories.Length > 0) | 679 | if(m_RemoveDirectories != null && m_RemoveDirectories.Length > 0) |
680 | { | 680 | { |
681 | try | 681 | try |
682 | { | 682 | { |
683 | RemoveDirectories(".",m_RemoveDirectories); | 683 | RemoveDirectories(".",m_RemoveDirectories); |
684 | } | 684 | } |
685 | catch(IOException e) | 685 | catch(IOException e) |
686 | { | 686 | { |
687 | m_Log.Write("Failed to remove directories named {0}",m_RemoveDirectories); | 687 | m_Log.Write("Failed to remove directories named {0}",m_RemoveDirectories); |
688 | m_Log.WriteException(LogType.Error,e); | 688 | m_Log.WriteException(LogType.Error,e); |
689 | } | 689 | } |
690 | catch(UnauthorizedAccessException e) | 690 | catch(UnauthorizedAccessException e) |
691 | { | 691 | { |
692 | m_Log.Write("Failed to remove directories named {0}",m_RemoveDirectories); | 692 | m_Log.Write("Failed to remove directories named {0}",m_RemoveDirectories); |
693 | m_Log.WriteException(LogType.Error,e); | 693 | m_Log.WriteException(LogType.Error,e); |
694 | } | 694 | } |
695 | perfomedOtherTask = true; | 695 | perfomedOtherTask = true; |
696 | } | 696 | } |
697 | 697 | ||
698 | if(m_Target != null && m_Clean != null) | 698 | if(m_Target != null && m_Clean != null) |
699 | { | 699 | { |
700 | m_Log.Write(LogType.Error, "The options /target and /clean cannot be passed together"); | 700 | m_Log.Write(LogType.Error, "The options /target and /clean cannot be passed together"); |
701 | return; | 701 | return; |
702 | } | 702 | } |
703 | 703 | ||
704 | if(m_Target == null && m_Clean == null) | 704 | if(m_Target == null && m_Clean == null) |
705 | { | 705 | { |
706 | if(perfomedOtherTask) //finished | 706 | if(perfomedOtherTask) //finished |
707 | { | 707 | { |
708 | return; | 708 | return; |
709 | } | 709 | } |
710 | m_Log.Write(LogType.Error, "Must pass either /target or /clean to process a Prebuild file"); | 710 | m_Log.Write(LogType.Error, "Must pass either /target or /clean to process a Prebuild file"); |
711 | return; | 711 | return; |
712 | } | 712 | } |
713 | 713 | ||
714 | string file = "./prebuild.xml"; | 714 | string file = "./prebuild.xml"; |
715 | if(m_CommandLine.WasPassed("file")) | 715 | if(m_CommandLine.WasPassed("file")) |
716 | { | 716 | { |
717 | file = m_CommandLine["file"]; | 717 | file = m_CommandLine["file"]; |
718 | } | 718 | } |
719 | 719 | ||
720 | ProcessFile(file); | 720 | ProcessFile(file); |
721 | 721 | ||
722 | string target = (m_Target != null ? m_Target.ToLower() : m_Clean.ToLower()); | 722 | string target = (m_Target != null ? m_Target.ToLower() : m_Clean.ToLower()); |
723 | bool clean = (m_Target == null); | 723 | bool clean = (m_Target == null); |
724 | if(clean && target != null && target.Length == 0) | 724 | if(clean && target != null && target.Length == 0) |
725 | { | 725 | { |
726 | target = "all"; | 726 | target = "all"; |
727 | } | 727 | } |
728 | if(clean && target == "all")//default to all if no target was specified for clean | 728 | if(clean && target == "all")//default to all if no target was specified for clean |
729 | { | 729 | { |
730 | //check if they passed yes | 730 | //check if they passed yes |
731 | if (!m_CommandLine.WasPassed("yes")) | 731 | if (!m_CommandLine.WasPassed("yes")) |
732 | { | 732 | { |
733 | Console.WriteLine("WARNING: This operation will clean ALL project files for all targets, are you sure? (y/n):"); | 733 | Console.WriteLine("WARNING: This operation will clean ALL project files for all targets, are you sure? (y/n):"); |
734 | string ret = Console.ReadLine(); | 734 | string ret = Console.ReadLine(); |
735 | if(ret == null) | 735 | if(ret == null) |
736 | { | 736 | { |
737 | return; | 737 | return; |
738 | } | ||
739 | ret = ret.Trim().ToLower(); | ||
740 | if((ret.ToLower() != "y" && ret.ToLower() != "yes")) | ||
741 | { | ||
742 | return; | ||
743 | } | 738 | } |
739 | ret = ret.Trim().ToLower(); | ||
740 | if((ret.ToLower() != "y" && ret.ToLower() != "yes")) | ||
741 | { | ||
742 | return; | ||
743 | } | ||
744 | } | ||
745 | //clean all targets (just cleaning vs2002 target didn't clean nant) | ||
746 | foreach(ITarget targ in m_Targets.Values) | ||
747 | { | ||
748 | targ.Clean(this); | ||
744 | } | 749 | } |
745 | //clean all targets (just cleaning vs2002 target didn't clean nant) | 750 | } |
746 | foreach(ITarget targ in m_Targets.Values) | 751 | else |
747 | { | 752 | { |
748 | targ.Clean(this); | 753 | if (!m_Targets.ContainsKey(target)) { |
749 | } | 754 | m_Log.Write(LogType.Error, "Unknown Target \"{0}\"", target); |
750 | } | 755 | return; |
751 | else | 756 | } |
752 | { | 757 | ITarget targ = m_Targets[target]; |
753 | if (!m_Targets.ContainsKey(target)) { | 758 | |
754 | m_Log.Write(LogType.Error, "Unknown Target \"{0}\"", target); | 759 | if(clean) |
755 | return; | 760 | { |
756 | } | 761 | targ.Clean(this); |
757 | ITarget targ = m_Targets[target]; | 762 | } |
758 | 763 | else | |
759 | if(clean) | 764 | { |
760 | { | 765 | targ.Write(this); |
761 | targ.Clean(this); | 766 | } |
762 | } | 767 | } |
763 | else | 768 | |
764 | { | 769 | m_Log.Flush(); |
765 | targ.Write(this); | 770 | } |
766 | } | 771 | |
767 | } | 772 | #endregion |
768 | 773 | ||
769 | m_Log.Flush(); | 774 | #region IDisposable Members |
770 | } | 775 | |
771 | 776 | /// <summary> | |
772 | #endregion | 777 | /// |
773 | 778 | /// </summary> | |
774 | #region IDisposable Members | 779 | public void Dispose() |
775 | 780 | { | |
776 | /// <summary> | 781 | Dispose(true); |
777 | /// | 782 | GC.SuppressFinalize(this); |
778 | /// </summary> | 783 | } |
779 | public void Dispose() | 784 | |
780 | { | 785 | /// <summary> |
781 | Dispose(true); | 786 | /// Dispose objects |
782 | GC.SuppressFinalize(this); | 787 | /// </summary> |
783 | } | 788 | /// <param name="disposing"> |
784 | 789 | /// If true, it will dispose close the handle | |
785 | /// <summary> | 790 | /// </param> |
786 | /// Dispose objects | 791 | /// <remarks> |
787 | /// </summary> | 792 | /// Will dispose managed and unmanaged resources. |
788 | /// <param name="disposing"> | 793 | /// </remarks> |
789 | /// If true, it will dispose close the handle | 794 | protected virtual void Dispose(bool disposing) |
790 | /// </param> | 795 | { |
791 | /// <remarks> | 796 | if (!disposed) |
792 | /// Will dispose managed and unmanaged resources. | 797 | { |
793 | /// </remarks> | 798 | if (disposing) |
794 | protected virtual void Dispose(bool disposing) | 799 | { |
795 | { | ||
796 | if (!disposed) | ||
797 | { | ||
798 | if (disposing) | ||
799 | { | ||
800 | GC.SuppressFinalize(this); | 800 | GC.SuppressFinalize(this); |
801 | if (m_Log != null) | 801 | if (m_Log != null) |
802 | { | 802 | { |
803 | m_Log.Close(); | 803 | m_Log.Close(); |
804 | m_Log = null; | 804 | m_Log = null; |
805 | } | 805 | } |
806 | } | 806 | } |
807 | } | 807 | } |
808 | disposed = true; | 808 | disposed = true; |
809 | } | 809 | } |
810 | 810 | ||
811 | /// <summary> | 811 | /// <summary> |
812 | /// | 812 | /// |
813 | /// </summary> | 813 | /// </summary> |
814 | ~Kernel() | 814 | ~Kernel() |
815 | { | 815 | { |
816 | Dispose(false); | 816 | Dispose(false); |
817 | } | 817 | } |
818 | 818 | ||
819 | /// <summary> | 819 | /// <summary> |
820 | /// Closes and destroys this object | 820 | /// Closes and destroys this object |
821 | /// </summary> | 821 | /// </summary> |
822 | /// <remarks> | 822 | /// <remarks> |
823 | /// Same as Dispose(true) | 823 | /// Same as Dispose(true) |
824 | /// </remarks> | 824 | /// </remarks> |
825 | public void Close() | 825 | public void Close() |
826 | { | 826 | { |
827 | Dispose(); | 827 | Dispose(); |
828 | } | 828 | } |
829 | 829 | ||
830 | #endregion | 830 | #endregion |
831 | } | 831 | } |
832 | } | 832 | } |