aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Prebuild/src/Core/Utilities
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2010-09-11 01:13:08 +0100
committerJustin Clark-Casey (justincc)2010-09-11 01:13:08 +0100
commit7e65590a55ba575d0086bdfc25addaf1051d799b (patch)
tree1dc11683170d45d80d7aab6eefdfcc836d3e773b /Prebuild/src/Core/Utilities
parentMake it clear that the "create region" command will reference ini files in th... (diff)
downloadopensim-SC-7e65590a55ba575d0086bdfc25addaf1051d799b.zip
opensim-SC-7e65590a55ba575d0086bdfc25addaf1051d799b.tar.gz
opensim-SC-7e65590a55ba575d0086bdfc25addaf1051d799b.tar.bz2
opensim-SC-7e65590a55ba575d0086bdfc25addaf1051d799b.tar.xz
Update Prebuild.exe with Prebuild r323 + an existing OpenSim specific nant hack to correctly clean up chosen OpenSim exes and dlls in bin/ on a "nant clean"
Source code is included for reference. This can go away again once Prebuild is updated with a more general mechanism for cleaning up files. The Prebuild source code here can be built with nant, or regnerated for other tools using the prebuild at {root}/bin/Prebuild.exe
Diffstat (limited to 'Prebuild/src/Core/Utilities')
-rw-r--r--Prebuild/src/Core/Utilities/.svn/all-wcprops29
-rw-r--r--Prebuild/src/Core/Utilities/.svn/dir-prop-base5
-rw-r--r--Prebuild/src/Core/Utilities/.svn/entries164
-rw-r--r--Prebuild/src/Core/Utilities/.svn/prop-base/CommandLineCollection.cs.svn-base9
-rw-r--r--Prebuild/src/Core/Utilities/.svn/prop-base/CurrentDirectory.cs.svn-base9
-rw-r--r--Prebuild/src/Core/Utilities/.svn/prop-base/Helper.cs.svn-base9
-rw-r--r--Prebuild/src/Core/Utilities/.svn/prop-base/Log.cs.svn-base9
-rw-r--r--Prebuild/src/Core/Utilities/.svn/text-base/CommandLineCollection.cs.svn-base152
-rw-r--r--Prebuild/src/Core/Utilities/.svn/text-base/CurrentDirectory.cs.svn-base68
-rw-r--r--Prebuild/src/Core/Utilities/.svn/text-base/Helper.cs.svn-base575
-rw-r--r--Prebuild/src/Core/Utilities/.svn/text-base/Log.cs.svn-base276
-rw-r--r--Prebuild/src/Core/Utilities/CommandLineCollection.cs152
-rw-r--r--Prebuild/src/Core/Utilities/CurrentDirectory.cs68
-rw-r--r--Prebuild/src/Core/Utilities/Helper.cs575
-rw-r--r--Prebuild/src/Core/Utilities/Log.cs276
15 files changed, 2376 insertions, 0 deletions
diff --git a/Prebuild/src/Core/Utilities/.svn/all-wcprops b/Prebuild/src/Core/Utilities/.svn/all-wcprops
new file mode 100644
index 0000000..7418c29
--- /dev/null
+++ b/Prebuild/src/Core/Utilities/.svn/all-wcprops
@@ -0,0 +1,29 @@
1K 25
2svn:wc:ra_dav:version-url
3V 60
4/svnroot/dnpb/!svn/ver/309/trunk/Prebuild/src/Core/Utilities
5END
6Helper.cs
7K 25
8svn:wc:ra_dav:version-url
9V 70
10/svnroot/dnpb/!svn/ver/307/trunk/Prebuild/src/Core/Utilities/Helper.cs
11END
12Log.cs
13K 25
14svn:wc:ra_dav:version-url
15V 67
16/svnroot/dnpb/!svn/ver/309/trunk/Prebuild/src/Core/Utilities/Log.cs
17END
18CommandLineCollection.cs
19K 25
20svn:wc:ra_dav:version-url
21V 85
22/svnroot/dnpb/!svn/ver/307/trunk/Prebuild/src/Core/Utilities/CommandLineCollection.cs
23END
24CurrentDirectory.cs
25K 25
26svn:wc:ra_dav:version-url
27V 80
28/svnroot/dnpb/!svn/ver/307/trunk/Prebuild/src/Core/Utilities/CurrentDirectory.cs
29END
diff --git a/Prebuild/src/Core/Utilities/.svn/dir-prop-base b/Prebuild/src/Core/Utilities/.svn/dir-prop-base
new file mode 100644
index 0000000..a1989a0
--- /dev/null
+++ b/Prebuild/src/Core/Utilities/.svn/dir-prop-base
@@ -0,0 +1,5 @@
1K 10
2svn:ignore
3V 5
4*.swp
5END
diff --git a/Prebuild/src/Core/Utilities/.svn/entries b/Prebuild/src/Core/Utilities/.svn/entries
new file mode 100644
index 0000000..cc148d7
--- /dev/null
+++ b/Prebuild/src/Core/Utilities/.svn/entries
@@ -0,0 +1,164 @@
110
2
3dir
4323
5https://dnpb.svn.sourceforge.net/svnroot/dnpb/trunk/Prebuild/src/Core/Utilities
6https://dnpb.svn.sourceforge.net/svnroot/dnpb
7
8
9
102009-04-15T01:40:10.014568Z
11309
12kunnis
13has-props
14
15
16
17
18
19
20
21
22
23
24
25
26
273355ff64-970d-0410-bbe8-d0fbd18be4fb
28
29Helper.cs
30file
31
32
33
34
352010-09-10T22:51:44.000000Z
367a0749dec0ce5453fc73dd11f89ce613
372009-04-15T01:28:16.827957Z
38307
39kunnis
40has-props
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
6114966
62
63Log.cs
64file
65
66
67
68
692010-09-10T22:51:44.000000Z
70d91804d20a90778d74744cd14bb2fa4c
712009-04-15T01:40:10.014568Z
72309
73kunnis
74has-props
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
956100
96
97CommandLineCollection.cs
98file
99
100
101
102
1032010-09-10T22:51:44.000000Z
1042a00bed45ea425e5e8a21a5ff6a68d69
1052009-04-15T01:28:16.827957Z
106307
107kunnis
108has-props
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
1294032
130
131CurrentDirectory.cs
132file
133
134
135
136
1372010-09-10T22:51:44.000000Z
138e710723e685cc628a3761209001c8767
1392009-04-15T01:28:16.827957Z
140307
141kunnis
142has-props
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
1632124
164
diff --git a/Prebuild/src/Core/Utilities/.svn/prop-base/CommandLineCollection.cs.svn-base b/Prebuild/src/Core/Utilities/.svn/prop-base/CommandLineCollection.cs.svn-base
new file mode 100644
index 0000000..7b57b30
--- /dev/null
+++ b/Prebuild/src/Core/Utilities/.svn/prop-base/CommandLineCollection.cs.svn-base
@@ -0,0 +1,9 @@
1K 13
2svn:eol-style
3V 6
4native
5K 12
6svn:keywords
7V 23
8Author Date Id Revision
9END
diff --git a/Prebuild/src/Core/Utilities/.svn/prop-base/CurrentDirectory.cs.svn-base b/Prebuild/src/Core/Utilities/.svn/prop-base/CurrentDirectory.cs.svn-base
new file mode 100644
index 0000000..7b57b30
--- /dev/null
+++ b/Prebuild/src/Core/Utilities/.svn/prop-base/CurrentDirectory.cs.svn-base
@@ -0,0 +1,9 @@
1K 13
2svn:eol-style
3V 6
4native
5K 12
6svn:keywords
7V 23
8Author Date Id Revision
9END
diff --git a/Prebuild/src/Core/Utilities/.svn/prop-base/Helper.cs.svn-base b/Prebuild/src/Core/Utilities/.svn/prop-base/Helper.cs.svn-base
new file mode 100644
index 0000000..7b57b30
--- /dev/null
+++ b/Prebuild/src/Core/Utilities/.svn/prop-base/Helper.cs.svn-base
@@ -0,0 +1,9 @@
1K 13
2svn:eol-style
3V 6
4native
5K 12
6svn:keywords
7V 23
8Author Date Id Revision
9END
diff --git a/Prebuild/src/Core/Utilities/.svn/prop-base/Log.cs.svn-base b/Prebuild/src/Core/Utilities/.svn/prop-base/Log.cs.svn-base
new file mode 100644
index 0000000..7b57b30
--- /dev/null
+++ b/Prebuild/src/Core/Utilities/.svn/prop-base/Log.cs.svn-base
@@ -0,0 +1,9 @@
1K 13
2svn:eol-style
3V 6
4native
5K 12
6svn:keywords
7V 23
8Author Date Id Revision
9END
diff --git a/Prebuild/src/Core/Utilities/.svn/text-base/CommandLineCollection.cs.svn-base b/Prebuild/src/Core/Utilities/.svn/text-base/CommandLineCollection.cs.svn-base
new file mode 100644
index 0000000..786fa1e
--- /dev/null
+++ b/Prebuild/src/Core/Utilities/.svn/text-base/CommandLineCollection.cs.svn-base
@@ -0,0 +1,152 @@
1#region BSD License
2/*
3Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com)
4
5Redistribution and use in source and binary forms, with or without modification, are permitted
6provided 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
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
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
20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23*/
24#endregion
25
26using System.Collections;
27using System.Collections.Generic;
28
29namespace Prebuild.Core.Utilities
30{
31 /// <summary>
32 /// The CommandLine class parses and interprets the command-line arguments passed to
33 /// prebuild.
34 /// </summary>
35 public class CommandLineCollection : IEnumerable<KeyValuePair<string, string>>
36 {
37 #region Fields
38
39 // The raw OS arguments
40 private readonly string[] m_RawArgs;
41
42 // Command-line argument storage
43 private readonly Dictionary<string, string> m_Arguments = new Dictionary<string, string>();
44
45 #endregion
46
47 #region Constructors
48
49 /// <summary>
50 /// Create a new CommandLine instance and set some internal variables.
51 /// </summary>
52 public CommandLineCollection(string[] args)
53 {
54 m_RawArgs = args;
55
56 Parse();
57 }
58
59 #endregion
60
61 #region Private Methods
62
63 private void Parse()
64 {
65 if(m_RawArgs.Length < 1)
66 return;
67
68 int idx = 0;
69 string lastArg = null;
70
71 while(idx <m_RawArgs.Length)
72 {
73 string arg = m_RawArgs[idx];
74
75 if(arg.Length > 2 && arg[0] == '/')
76 {
77 arg = arg.Substring(1);
78 lastArg = arg;
79 m_Arguments[arg] = "";
80 }
81 else
82 {
83 if(lastArg != null)
84 {
85 m_Arguments[lastArg] = arg;
86 lastArg = null;
87 }
88 }
89
90 idx++;
91 }
92 }
93
94 #endregion
95
96 #region Public Methods
97
98 /// <summary>
99 /// Wases the passed.
100 /// </summary>
101 /// <param name="arg">The arg.</param>
102 /// <returns></returns>
103 public bool WasPassed(string arg)
104 {
105 return (m_Arguments.ContainsKey(arg));
106 }
107
108 #endregion
109
110 #region Properties
111
112 /// <summary>
113 /// Gets the parameter associated with the command line option
114 /// </summary>
115 /// <remarks>Returns null if option was not specified,
116 /// null string if no parameter was specified, and the value if a parameter was specified</remarks>
117 public string this[string index]
118 {
119 get
120 {
121 if(m_Arguments.ContainsKey(index))
122 {
123 return (m_Arguments[index]);
124 }
125 return null;
126 }
127 }
128
129 #endregion
130
131 #region IEnumerable Members
132
133 /// <summary>
134 /// Returns an enumerator that can iterate through a collection.
135 /// </summary>
136 /// <returns>
137 /// An <see cref="T:System.Collections.IDictionaryEnumerator"/>
138 /// that can be used to iterate through the collection.
139 /// </returns>
140 public IEnumerator<KeyValuePair<string, string>> GetEnumerator()
141 {
142 return m_Arguments.GetEnumerator();
143 }
144
145 IEnumerator IEnumerable.GetEnumerator()
146 {
147 return GetEnumerator();
148 }
149
150 #endregion
151 }
152}
diff --git a/Prebuild/src/Core/Utilities/.svn/text-base/CurrentDirectory.cs.svn-base b/Prebuild/src/Core/Utilities/.svn/text-base/CurrentDirectory.cs.svn-base
new file mode 100644
index 0000000..9624c35
--- /dev/null
+++ b/Prebuild/src/Core/Utilities/.svn/text-base/CurrentDirectory.cs.svn-base
@@ -0,0 +1,68 @@
1#region BSD License
2/*
3Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com)
4
5Redistribution and use in source and binary forms, with or without modification, are permitted
6provided 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
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
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
20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23*/
24#endregion
25
26using System;
27using System.Collections.Generic;
28
29namespace Prebuild.Core.Utilities
30{
31 /// <summary>
32 ///
33 /// </summary>
34 public class CurrentDirectory
35 {
36 #region Fields
37
38 private readonly Stack<string> m_Stack = new Stack<string>();
39
40 #endregion
41
42 #region Public Methods
43
44 /// <summary>
45 /// Pushes this instance.
46 /// </summary>
47 public void Push()
48 {
49 m_Stack.Push(Environment.CurrentDirectory);
50 }
51
52 /// <summary>
53 /// Pops this instance.
54 /// </summary>
55 public void Pop()
56 {
57 if(m_Stack.Count < 1)
58 {
59 return;
60 }
61
62 string cwd = m_Stack.Pop();
63 Helper.SetCurrentDir(cwd);
64 }
65
66 #endregion
67 }
68}
diff --git a/Prebuild/src/Core/Utilities/.svn/text-base/Helper.cs.svn-base b/Prebuild/src/Core/Utilities/.svn/text-base/Helper.cs.svn-base
new file mode 100644
index 0000000..8c3e968
--- /dev/null
+++ b/Prebuild/src/Core/Utilities/.svn/text-base/Helper.cs.svn-base
@@ -0,0 +1,575 @@
1#region BSD License
2/*
3Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com)
4
5Redistribution and use in source and binary forms, with or without modification, are permitted
6provided 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
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
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
20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23*/
24#endregion
25
26using System;
27using System.Collections.Generic;
28using System.Diagnostics;
29using System.IO;
30using System.Runtime.InteropServices;
31using System.Text.RegularExpressions;
32using System.Collections.Specialized;
33using System.Xml;
34using Prebuild.Core.Nodes;
35
36namespace Prebuild.Core.Utilities
37{
38 /// <summary>
39 ///
40 /// </summary>
41 public class Helper
42 {
43 #region Fields
44
45 static bool checkForOSVariables;
46
47 /// <summary>
48 ///
49 /// </summary>
50 public static bool CheckForOSVariables
51 {
52 get
53 {
54 return checkForOSVariables;
55 }
56 set
57 {
58 checkForOSVariables = value;
59 }
60 }
61
62 #endregion
63
64 #region Public Methods
65
66 #region String Parsing
67
68 public delegate string StringLookup(string key);
69
70 /// <summary>
71 /// Gets a collection of StringLocationPair objects that represent the matches
72 /// </summary>
73 /// <param name="target">The target.</param>
74 /// <param name="beforeGroup">The before group.</param>
75 /// <param name="afterGroup">The after group.</param>
76 /// <param name="includeDelimitersInSubstrings">if set to <c>true</c> [include delimiters in substrings].</param>
77 /// <returns></returns>
78 public static StringCollection FindGroups(string target, string beforeGroup, string afterGroup, bool includeDelimitersInSubstrings)
79 {
80 if( beforeGroup == null )
81 {
82 throw new ArgumentNullException("beforeGroup");
83 }
84 if( afterGroup == null )
85 {
86 throw new ArgumentNullException("afterGroup");
87 }
88 StringCollection results = new StringCollection();
89 if(target == null || target.Length == 0)
90 {
91 return results;
92 }
93
94 int beforeMod = 0;
95 int afterMod = 0;
96 if(includeDelimitersInSubstrings)
97 {
98 //be sure to not exlude the delims
99 beforeMod = beforeGroup.Length;
100 afterMod = afterGroup.Length;
101 }
102 int startIndex = 0;
103 while((startIndex = target.IndexOf(beforeGroup,startIndex)) != -1) {
104 int endIndex = target.IndexOf(afterGroup,startIndex);//the index of the char after it
105 if(endIndex == -1)
106 {
107 break;
108 }
109 int length = endIndex - startIndex - beforeGroup.Length;//move to the first char in the string
110 string substring = substring = target.Substring(startIndex + beforeGroup.Length - beforeMod,
111 length - afterMod);
112
113 results.Add(substring);
114 //results.Add(new StringLocationPair(substring,startIndex));
115 startIndex = endIndex + 1;
116 //the Interpolate*() methods will not work if expressions are expandded inside expression due to an optimization
117 //so start after endIndex
118
119 }
120 return results;
121 }
122
123 /// <summary>
124 /// Replaces the groups.
125 /// </summary>
126 /// <param name="target">The target.</param>
127 /// <param name="beforeGroup">The before group.</param>
128 /// <param name="afterGroup">The after group.</param>
129 /// <param name="lookup">The lookup.</param>
130 /// <returns></returns>
131 public static string ReplaceGroups(string target, string beforeGroup, string afterGroup, StringLookup lookup) {
132 if( target == null )
133 {
134 throw new ArgumentNullException("target");
135 }
136 //int targetLength = target.Length;
137 StringCollection strings = FindGroups(target,beforeGroup,afterGroup,false);
138 if( lookup == null )
139 {
140 throw new ArgumentNullException("lookup");
141 }
142 foreach(string substring in strings)
143 {
144 target = target.Replace(beforeGroup + substring + afterGroup, lookup(substring) );
145 }
146 return target;
147 }
148
149 /// <summary>
150 /// Replaces ${var} statements in a string with the corresonding values as detirmined by the lookup delegate
151 /// </summary>
152 /// <param name="target">The target.</param>
153 /// <param name="lookup">The lookup.</param>
154 /// <returns></returns>
155 public static string InterpolateForVariables(string target, StringLookup lookup)
156 {
157 return ReplaceGroups(target, "${" , "}" , lookup);
158 }
159
160 /// <summary>
161 /// Replaces ${var} statements in a string with the corresonding environment variable with name var
162 /// </summary>
163 /// <param name="target"></param>
164 /// <returns></returns>
165 public static string InterpolateForEnvironmentVariables(string target)
166 {
167 return InterpolateForVariables(target, new StringLookup(Environment.GetEnvironmentVariable));
168 }
169
170 #endregion
171
172 /// <summary>
173 /// Translates the value.
174 /// </summary>
175 /// <param name="translateType">Type of the translate.</param>
176 /// <param name="translationItem">The translation item.</param>
177 /// <returns></returns>
178 public static object TranslateValue(Type translateType, string translationItem)
179 {
180 if(translationItem == null)
181 {
182 return null;
183 }
184
185 try
186 {
187 string lowerVal = translationItem.ToLower();
188 if(translateType == typeof(bool))
189 {
190 return (lowerVal == "true" || lowerVal == "1" || lowerVal == "y" || lowerVal == "yes" || lowerVal == "on");
191 }
192 else if(translateType == typeof(int))
193 {
194 return (Int32.Parse(translationItem));
195 }
196 else
197 {
198 return translationItem;
199 }
200 }
201 catch(FormatException)
202 {
203 return null;
204 }
205 }
206
207 /// <summary>
208 /// Deletes if exists.
209 /// </summary>
210 /// <param name="file">The file.</param>
211 /// <returns></returns>
212 public static bool DeleteIfExists(string file)
213 {
214 string resFile = null;
215 try
216 {
217 resFile = ResolvePath(file);
218 }
219 catch(ArgumentException)
220 {
221 return false;
222 }
223
224 if(!File.Exists(resFile))
225 {
226 return false;
227 }
228
229 File.Delete(resFile);
230 return true;
231 }
232
233 static readonly char seperator = Path.DirectorySeparatorChar;
234
235 // This little gem was taken from the NeL source, thanks guys!
236 /// <summary>
237 /// Makes a relative path
238 /// </summary>
239 /// <param name="startPath">Path to start from</param>
240 /// <param name="endPath">Path to end at</param>
241 /// <returns>Path that will get from startPath to endPath</returns>
242 public static string MakePathRelativeTo(string startPath, string endPath)
243 {
244 string tmp = NormalizePath(startPath, seperator);
245 string src = NormalizePath(endPath, seperator);
246 string prefix = "";
247
248 while(true)
249 {
250 if((String.Compare(tmp, 0, src, 0, tmp.Length) == 0))
251 {
252 string ret;
253 int size = tmp.Length;
254 if(size == src.Length)
255 {
256 return "./";
257 }
258 if((src.Length > tmp.Length) && src[tmp.Length - 1] != seperator)
259 {
260 }
261 else
262 {
263 ret = prefix + endPath.Substring(size, endPath.Length - size);
264 ret = ret.Trim();
265 if(ret[0] == seperator)
266 {
267 ret = "." + ret;
268 }
269
270 return NormalizePath(ret);
271 }
272
273 }
274
275 if(tmp.Length < 2)
276 {
277 break;
278 }
279
280 int lastPos = tmp.LastIndexOf(seperator, tmp.Length - 2);
281 int prevPos = tmp.IndexOf(seperator);
282
283 if((lastPos == prevPos) || (lastPos == -1))
284 {
285 break;
286 }
287
288 tmp = tmp.Substring(0, lastPos + 1);
289 prefix += ".." + seperator.ToString();
290 }
291
292 return endPath;
293 }
294
295 /// <summary>
296 /// Resolves the path.
297 /// </summary>
298 /// <param name="path">The path.</param>
299 /// <returns></returns>
300 public static string ResolvePath(string path)
301 {
302 string tmpPath = NormalizePath(path);
303 if(tmpPath.Length < 1)
304 {
305 tmpPath = ".";
306 }
307
308 tmpPath = Path.GetFullPath(tmpPath);
309 if(!File.Exists(tmpPath) && !Directory.Exists(tmpPath))
310 {
311 throw new ArgumentException("Path could not be resolved: " + tmpPath);
312 }
313
314 return tmpPath;
315 }
316
317 /// <summary>
318 /// Normalizes the path.
319 /// </summary>
320 /// <param name="path">The path.</param>
321 /// <param name="separatorCharacter">The separator character.</param>
322 /// <returns></returns>
323 public static string NormalizePath(string path, char separatorCharacter)
324 {
325 if(path == null || path == "" || path.Length < 1)
326 {
327 return "";
328 }
329
330 string tmpPath = path.Replace('\\', '/');
331 tmpPath = tmpPath.Replace('/', separatorCharacter);
332 return tmpPath;
333 }
334
335 /// <summary>
336 /// Normalizes the path.
337 /// </summary>
338 /// <param name="path">The path.</param>
339 /// <returns></returns>
340 public static string NormalizePath(string path)
341 {
342 return NormalizePath(path, Path.DirectorySeparatorChar);
343 }
344
345 /// <summary>
346 /// Ends the path.
347 /// </summary>
348 /// <param name="path">The path.</param>
349 /// <param name="separatorCharacter">The separator character.</param>
350 /// <returns></returns>
351 public static string EndPath(string path, char separatorCharacter)
352 {
353 if(path == null || path == "" || path.Length < 1)
354 {
355 return "";
356 }
357
358 if(!path.EndsWith(separatorCharacter.ToString()))
359 {
360 return (path + separatorCharacter);
361 }
362
363 return path;
364 }
365
366 /// <summary>
367 /// Ends the path.
368 /// </summary>
369 /// <param name="path">The path.</param>
370 /// <returns></returns>
371 public static string EndPath(string path)
372 {
373 return EndPath(path, Path.DirectorySeparatorChar);
374 }
375
376 /// <summary>
377 /// Makes the file path.
378 /// </summary>
379 /// <param name="path">The path.</param>
380 /// <param name="name">The name.</param>
381 /// <param name="ext">The ext.</param>
382 /// <returns></returns>
383 public static string MakeFilePath(string path, string name, string ext)
384 {
385 string ret = EndPath(NormalizePath(path));
386
387 if( name == null )
388 {
389 throw new ArgumentNullException("name");
390 }
391
392 ret += name;
393 if(!name.EndsWith("." + ext))
394 {
395 ret += "." + ext;
396 }
397
398 //foreach(char c in Path.GetInvalidPathChars())
399 //{
400 // ret = ret.Replace(c, '_');
401 //}
402
403 return ret;
404 }
405
406 /// <summary>
407 /// Makes the file path.
408 /// </summary>
409 /// <param name="path">The path.</param>
410 /// <param name="name">The name.</param>
411 /// <returns></returns>
412 public static string MakeFilePath(string path, string name)
413 {
414 string ret = EndPath(NormalizePath(path));
415
416 if( name == null )
417 {
418 throw new ArgumentNullException("name");
419 }
420
421 ret += name;
422
423 //foreach (char c in Path.GetInvalidPathChars())
424 //{
425 // ret = ret.Replace(c, '_');
426 //}
427
428 return ret;
429 }
430
431 /// <summary>
432 ///
433 /// </summary>
434 /// <param name="path"></param>
435 /// <returns></returns>
436 public static string MakeReferencePath(string path)
437 {
438 string ret = EndPath(NormalizePath(path));
439
440 //foreach (char c in Path.GetInvalidPathChars())
441 //{
442 // ret = ret.Replace(c, '_');
443 //}
444
445 return ret;
446 }
447
448 /// <summary>
449 /// Sets the current dir.
450 /// </summary>
451 /// <param name="path">The path.</param>
452 public static void SetCurrentDir(string path)
453 {
454 if( path == null )
455 {
456 throw new ArgumentNullException("path");
457 }
458 if(path.Length < 1)
459 {
460 return;
461 }
462
463 Environment.CurrentDirectory = path;
464 }
465
466 /// <summary>
467 /// Checks the type.
468 /// </summary>
469 /// <param name="typeToCheck">The type to check.</param>
470 /// <param name="attr">The attr.</param>
471 /// <param name="inter">The inter.</param>
472 /// <returns></returns>
473 public static object CheckType(Type typeToCheck, Type attr, Type inter)
474 {
475 if(typeToCheck == null || attr == null)
476 {
477 return null;
478 }
479
480 object[] attrs = typeToCheck.GetCustomAttributes(attr, false);
481 if(attrs == null || attrs.Length < 1)
482 {
483 return null;
484 }
485 if( inter == null )
486 {
487 throw new ArgumentNullException("inter");
488 }
489
490 if(typeToCheck.GetInterface(inter.FullName) == null)
491 {
492 return null;
493 }
494
495 return attrs[0];
496 }
497
498 /// <summary>
499 /// Attributes the value.
500 /// </summary>
501 /// <param name="node">The node.</param>
502 /// <param name="attr">The attr.</param>
503 /// <param name="def">The def.</param>
504 /// <returns></returns>
505 public static string AttributeValue(XmlNode node, string attr, string def)
506 {
507 if( node == null )
508 {
509 throw new ArgumentNullException("node");
510 }
511 if(node.Attributes[attr] == null)
512 {
513 return def;
514 }
515 string val = node.Attributes[attr].Value;
516 if(!CheckForOSVariables)
517 {
518 return val;
519 }
520
521 return InterpolateForEnvironmentVariables(val);
522 }
523
524 /// <summary>
525 /// Parses the boolean.
526 /// </summary>
527 /// <param name="node">The node.</param>
528 /// <param name="attr">The attr.</param>
529 /// <param name="defaultValue">if set to <c>true</c> [default value].</param>
530 /// <returns></returns>
531 public static bool ParseBoolean(XmlNode node, string attr, bool defaultValue)
532 {
533 if( node == null )
534 {
535 throw new ArgumentNullException("node");
536 }
537 if(node.Attributes[attr] == null)
538 {
539 return defaultValue;
540 }
541 return bool.Parse(node.Attributes[attr].Value);
542 }
543
544 /// <summary>
545 /// Enums the attribute value.
546 /// </summary>
547 /// <param name="node">The node.</param>
548 /// <param name="attr">The attr.</param>
549 /// <param name="enumType">Type of the enum.</param>
550 /// <param name="def">The def.</param>
551 /// <returns></returns>
552 public static object EnumAttributeValue(XmlNode node, string attr, Type enumType, object def)
553 {
554 if( def == null )
555 {
556 throw new ArgumentNullException("def");
557 }
558 string val = AttributeValue(node, attr, def.ToString());
559 return Enum.Parse(enumType, val, true);
560 }
561
562 /// <summary>
563 ///
564 /// </summary>
565 /// <param name="assemblyName"></param>
566 /// <param name="projectType"></param>
567 /// <returns></returns>
568 public static string AssemblyFullName(string assemblyName, ProjectType projectType)
569 {
570 return assemblyName + (projectType == ProjectType.Library ? ".dll" : ".exe");
571 }
572
573 #endregion
574 }
575}
diff --git a/Prebuild/src/Core/Utilities/.svn/text-base/Log.cs.svn-base b/Prebuild/src/Core/Utilities/.svn/text-base/Log.cs.svn-base
new file mode 100644
index 0000000..4df3def
--- /dev/null
+++ b/Prebuild/src/Core/Utilities/.svn/text-base/Log.cs.svn-base
@@ -0,0 +1,276 @@
1#region BSD License
2/*
3Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com)
4
5Redistribution and use in source and binary forms, with or without modification, are permitted
6provided 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
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
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
20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23*/
24#endregion
25
26using System;
27using System.IO;
28
29namespace Prebuild.Core.Utilities
30{
31 /// <summary>
32 ///
33 /// </summary>
34 public enum LogType
35 {
36 /// <summary>
37 ///
38 /// </summary>
39 None,
40 /// <summary>
41 ///
42 /// </summary>
43 Info,
44 /// <summary>
45 ///
46 /// </summary>
47 Warning,
48 /// <summary>
49 ///
50 /// </summary>
51 Error
52 }
53
54 /// <summary>
55 ///
56 /// </summary>
57 [Flags]
58 public enum LogTargets
59 {
60 /// <summary>
61 ///
62 /// </summary>
63 None = 0,
64 /// <summary>
65 ///
66 /// </summary>
67 Null = 1,
68 /// <summary>
69 ///
70 /// </summary>
71 File = 2,
72 /// <summary>
73 ///
74 /// </summary>
75 Console = 4
76 }
77
78 /// <summary>
79 /// Summary description for Log.
80 /// </summary>
81 public class Log : IDisposable
82 {
83 #region Fields
84
85 private TextWriter m_Writer;
86 private LogTargets m_Target = LogTargets.Null;
87 bool disposed;
88
89 #endregion
90
91 #region Constructors
92
93 /// <summary>
94 /// Initializes a new instance of the <see cref="Log"/> class.
95 /// </summary>
96 /// <param name="target">The target.</param>
97 /// <param name="fileName">Name of the file.</param>
98 public Log(LogTargets target, string fileName)
99 {
100 m_Target = target;
101
102 if ((m_Target & LogTargets.File) != 0)
103 {
104 m_Writer = new StreamWriter(fileName, false);
105 }
106 else if ((m_Target & LogTargets.Console) != 0)
107 {
108 // Prevents null reference exceptions when outputing to the log file.
109 // This seems to only happen when running on a network drive.
110 m_Writer = Console.Out;
111 }
112 }
113
114 #endregion
115
116 #region Public Methods
117
118 /// <summary>
119 /// Writes this instance.
120 /// </summary>
121 public void Write()
122 {
123 Write(string.Empty);
124 }
125
126 /// <summary>
127 /// Writes the specified MSG.
128 /// </summary>
129 /// <param name="msg">The MSG.</param>
130 public void Write(string msg)
131 {
132 if((m_Target & LogTargets.Null) != 0)
133 {
134 return;
135 }
136
137 if((m_Target & LogTargets.Console) != 0)
138 {
139 Console.WriteLine(msg);
140 }
141 if((m_Target & LogTargets.File) != 0 && m_Writer != null)
142 {
143 m_Writer.WriteLine(msg);
144 }
145 }
146
147 /// <summary>
148 /// Writes the specified format.
149 /// </summary>
150 /// <param name="format">The format.</param>
151 /// <param name="args">The args.</param>
152 public void Write(string format, params object[] args)
153 {
154 Write(string.Format(format,args));
155 }
156
157 /// <summary>
158 /// Writes the specified type.
159 /// </summary>
160 /// <param name="type">The type.</param>
161 /// <param name="format">The format.</param>
162 /// <param name="args">The args.</param>
163 public void Write(LogType type, string format, params object[] args)
164 {
165 if((m_Target & LogTargets.Null) != 0)
166 {
167 return;
168 }
169
170 string str = "";
171 switch(type)
172 {
173 case LogType.Info:
174 str = "[I] ";
175 break;
176 case LogType.Warning:
177 str = "[!] ";
178 break;
179 case LogType.Error:
180 str = "[X] ";
181 break;
182 }
183
184 Write(str + format,args);
185 }
186
187 /// <summary>
188 /// Writes the exception.
189 /// </summary>
190 /// <param name="type">The type.</param>
191 /// <param name="ex">The ex.</param>
192 public void WriteException(LogType type, Exception ex)
193 {
194 if(ex != null)
195 {
196 Write(type, ex.Message);
197 //#if DEBUG
198 m_Writer.WriteLine("Exception @{0} stack trace [[", ex.TargetSite.Name);
199 m_Writer.WriteLine(ex.StackTrace);
200 m_Writer.WriteLine("]]");
201 //#endif
202 }
203 }
204
205 /// <summary>
206 /// Flushes this instance.
207 /// </summary>
208 public void Flush()
209 {
210 if(m_Writer != null)
211 {
212 m_Writer.Flush();
213 }
214 }
215
216 #endregion
217
218 #region IDisposable Members
219
220 /// <summary>
221 /// Performs application-defined tasks associated with freeing, releasing, or
222 /// resetting unmanaged resources.
223 /// </summary>
224 public void Dispose()
225 {
226 Dispose(true);
227 GC.SuppressFinalize(this);
228 }
229
230 /// <summary>
231 /// Dispose objects
232 /// </summary>
233 /// <param name="disposing">
234 /// If true, it will dispose close the handle
235 /// </param>
236 /// <remarks>
237 /// Will dispose managed and unmanaged resources.
238 /// </remarks>
239 protected virtual void Dispose(bool disposing)
240 {
241 if (!this.disposed)
242 {
243 if (disposing)
244 {
245 if (m_Writer != null)
246 {
247 m_Writer.Close();
248 m_Writer = null;
249 }
250 }
251 }
252 this.disposed = true;
253 }
254
255 /// <summary>
256 ///
257 /// </summary>
258 ~Log()
259 {
260 this.Dispose(false);
261 }
262
263 /// <summary>
264 /// Closes and destroys this object
265 /// </summary>
266 /// <remarks>
267 /// Same as Dispose(true)
268 /// </remarks>
269 public void Close()
270 {
271 Dispose();
272 }
273
274 #endregion
275 }
276}
diff --git a/Prebuild/src/Core/Utilities/CommandLineCollection.cs b/Prebuild/src/Core/Utilities/CommandLineCollection.cs
new file mode 100644
index 0000000..786fa1e
--- /dev/null
+++ b/Prebuild/src/Core/Utilities/CommandLineCollection.cs
@@ -0,0 +1,152 @@
1#region BSD License
2/*
3Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com)
4
5Redistribution and use in source and binary forms, with or without modification, are permitted
6provided 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
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
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
20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23*/
24#endregion
25
26using System.Collections;
27using System.Collections.Generic;
28
29namespace Prebuild.Core.Utilities
30{
31 /// <summary>
32 /// The CommandLine class parses and interprets the command-line arguments passed to
33 /// prebuild.
34 /// </summary>
35 public class CommandLineCollection : IEnumerable<KeyValuePair<string, string>>
36 {
37 #region Fields
38
39 // The raw OS arguments
40 private readonly string[] m_RawArgs;
41
42 // Command-line argument storage
43 private readonly Dictionary<string, string> m_Arguments = new Dictionary<string, string>();
44
45 #endregion
46
47 #region Constructors
48
49 /// <summary>
50 /// Create a new CommandLine instance and set some internal variables.
51 /// </summary>
52 public CommandLineCollection(string[] args)
53 {
54 m_RawArgs = args;
55
56 Parse();
57 }
58
59 #endregion
60
61 #region Private Methods
62
63 private void Parse()
64 {
65 if(m_RawArgs.Length < 1)
66 return;
67
68 int idx = 0;
69 string lastArg = null;
70
71 while(idx <m_RawArgs.Length)
72 {
73 string arg = m_RawArgs[idx];
74
75 if(arg.Length > 2 && arg[0] == '/')
76 {
77 arg = arg.Substring(1);
78 lastArg = arg;
79 m_Arguments[arg] = "";
80 }
81 else
82 {
83 if(lastArg != null)
84 {
85 m_Arguments[lastArg] = arg;
86 lastArg = null;
87 }
88 }
89
90 idx++;
91 }
92 }
93
94 #endregion
95
96 #region Public Methods
97
98 /// <summary>
99 /// Wases the passed.
100 /// </summary>
101 /// <param name="arg">The arg.</param>
102 /// <returns></returns>
103 public bool WasPassed(string arg)
104 {
105 return (m_Arguments.ContainsKey(arg));
106 }
107
108 #endregion
109
110 #region Properties
111
112 /// <summary>
113 /// Gets the parameter associated with the command line option
114 /// </summary>
115 /// <remarks>Returns null if option was not specified,
116 /// null string if no parameter was specified, and the value if a parameter was specified</remarks>
117 public string this[string index]
118 {
119 get
120 {
121 if(m_Arguments.ContainsKey(index))
122 {
123 return (m_Arguments[index]);
124 }
125 return null;
126 }
127 }
128
129 #endregion
130
131 #region IEnumerable Members
132
133 /// <summary>
134 /// Returns an enumerator that can iterate through a collection.
135 /// </summary>
136 /// <returns>
137 /// An <see cref="T:System.Collections.IDictionaryEnumerator"/>
138 /// that can be used to iterate through the collection.
139 /// </returns>
140 public IEnumerator<KeyValuePair<string, string>> GetEnumerator()
141 {
142 return m_Arguments.GetEnumerator();
143 }
144
145 IEnumerator IEnumerable.GetEnumerator()
146 {
147 return GetEnumerator();
148 }
149
150 #endregion
151 }
152}
diff --git a/Prebuild/src/Core/Utilities/CurrentDirectory.cs b/Prebuild/src/Core/Utilities/CurrentDirectory.cs
new file mode 100644
index 0000000..9624c35
--- /dev/null
+++ b/Prebuild/src/Core/Utilities/CurrentDirectory.cs
@@ -0,0 +1,68 @@
1#region BSD License
2/*
3Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com)
4
5Redistribution and use in source and binary forms, with or without modification, are permitted
6provided 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
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
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
20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23*/
24#endregion
25
26using System;
27using System.Collections.Generic;
28
29namespace Prebuild.Core.Utilities
30{
31 /// <summary>
32 ///
33 /// </summary>
34 public class CurrentDirectory
35 {
36 #region Fields
37
38 private readonly Stack<string> m_Stack = new Stack<string>();
39
40 #endregion
41
42 #region Public Methods
43
44 /// <summary>
45 /// Pushes this instance.
46 /// </summary>
47 public void Push()
48 {
49 m_Stack.Push(Environment.CurrentDirectory);
50 }
51
52 /// <summary>
53 /// Pops this instance.
54 /// </summary>
55 public void Pop()
56 {
57 if(m_Stack.Count < 1)
58 {
59 return;
60 }
61
62 string cwd = m_Stack.Pop();
63 Helper.SetCurrentDir(cwd);
64 }
65
66 #endregion
67 }
68}
diff --git a/Prebuild/src/Core/Utilities/Helper.cs b/Prebuild/src/Core/Utilities/Helper.cs
new file mode 100644
index 0000000..8c3e968
--- /dev/null
+++ b/Prebuild/src/Core/Utilities/Helper.cs
@@ -0,0 +1,575 @@
1#region BSD License
2/*
3Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com)
4
5Redistribution and use in source and binary forms, with or without modification, are permitted
6provided 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
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
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
20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23*/
24#endregion
25
26using System;
27using System.Collections.Generic;
28using System.Diagnostics;
29using System.IO;
30using System.Runtime.InteropServices;
31using System.Text.RegularExpressions;
32using System.Collections.Specialized;
33using System.Xml;
34using Prebuild.Core.Nodes;
35
36namespace Prebuild.Core.Utilities
37{
38 /// <summary>
39 ///
40 /// </summary>
41 public class Helper
42 {
43 #region Fields
44
45 static bool checkForOSVariables;
46
47 /// <summary>
48 ///
49 /// </summary>
50 public static bool CheckForOSVariables
51 {
52 get
53 {
54 return checkForOSVariables;
55 }
56 set
57 {
58 checkForOSVariables = value;
59 }
60 }
61
62 #endregion
63
64 #region Public Methods
65
66 #region String Parsing
67
68 public delegate string StringLookup(string key);
69
70 /// <summary>
71 /// Gets a collection of StringLocationPair objects that represent the matches
72 /// </summary>
73 /// <param name="target">The target.</param>
74 /// <param name="beforeGroup">The before group.</param>
75 /// <param name="afterGroup">The after group.</param>
76 /// <param name="includeDelimitersInSubstrings">if set to <c>true</c> [include delimiters in substrings].</param>
77 /// <returns></returns>
78 public static StringCollection FindGroups(string target, string beforeGroup, string afterGroup, bool includeDelimitersInSubstrings)
79 {
80 if( beforeGroup == null )
81 {
82 throw new ArgumentNullException("beforeGroup");
83 }
84 if( afterGroup == null )
85 {
86 throw new ArgumentNullException("afterGroup");
87 }
88 StringCollection results = new StringCollection();
89 if(target == null || target.Length == 0)
90 {
91 return results;
92 }
93
94 int beforeMod = 0;
95 int afterMod = 0;
96 if(includeDelimitersInSubstrings)
97 {
98 //be sure to not exlude the delims
99 beforeMod = beforeGroup.Length;
100 afterMod = afterGroup.Length;
101 }
102 int startIndex = 0;
103 while((startIndex = target.IndexOf(beforeGroup,startIndex)) != -1) {
104 int endIndex = target.IndexOf(afterGroup,startIndex);//the index of the char after it
105 if(endIndex == -1)
106 {
107 break;
108 }
109 int length = endIndex - startIndex - beforeGroup.Length;//move to the first char in the string
110 string substring = substring = target.Substring(startIndex + beforeGroup.Length - beforeMod,
111 length - afterMod);
112
113 results.Add(substring);
114 //results.Add(new StringLocationPair(substring,startIndex));
115 startIndex = endIndex + 1;
116 //the Interpolate*() methods will not work if expressions are expandded inside expression due to an optimization
117 //so start after endIndex
118
119 }
120 return results;
121 }
122
123 /// <summary>
124 /// Replaces the groups.
125 /// </summary>
126 /// <param name="target">The target.</param>
127 /// <param name="beforeGroup">The before group.</param>
128 /// <param name="afterGroup">The after group.</param>
129 /// <param name="lookup">The lookup.</param>
130 /// <returns></returns>
131 public static string ReplaceGroups(string target, string beforeGroup, string afterGroup, StringLookup lookup) {
132 if( target == null )
133 {
134 throw new ArgumentNullException("target");
135 }
136 //int targetLength = target.Length;
137 StringCollection strings = FindGroups(target,beforeGroup,afterGroup,false);
138 if( lookup == null )
139 {
140 throw new ArgumentNullException("lookup");
141 }
142 foreach(string substring in strings)
143 {
144 target = target.Replace(beforeGroup + substring + afterGroup, lookup(substring) );
145 }
146 return target;
147 }
148
149 /// <summary>
150 /// Replaces ${var} statements in a string with the corresonding values as detirmined by the lookup delegate
151 /// </summary>
152 /// <param name="target">The target.</param>
153 /// <param name="lookup">The lookup.</param>
154 /// <returns></returns>
155 public static string InterpolateForVariables(string target, StringLookup lookup)
156 {
157 return ReplaceGroups(target, "${" , "}" , lookup);
158 }
159
160 /// <summary>
161 /// Replaces ${var} statements in a string with the corresonding environment variable with name var
162 /// </summary>
163 /// <param name="target"></param>
164 /// <returns></returns>
165 public static string InterpolateForEnvironmentVariables(string target)
166 {
167 return InterpolateForVariables(target, new StringLookup(Environment.GetEnvironmentVariable));
168 }
169
170 #endregion
171
172 /// <summary>
173 /// Translates the value.
174 /// </summary>
175 /// <param name="translateType">Type of the translate.</param>
176 /// <param name="translationItem">The translation item.</param>
177 /// <returns></returns>
178 public static object TranslateValue(Type translateType, string translationItem)
179 {
180 if(translationItem == null)
181 {
182 return null;
183 }
184
185 try
186 {
187 string lowerVal = translationItem.ToLower();
188 if(translateType == typeof(bool))
189 {
190 return (lowerVal == "true" || lowerVal == "1" || lowerVal == "y" || lowerVal == "yes" || lowerVal == "on");
191 }
192 else if(translateType == typeof(int))
193 {
194 return (Int32.Parse(translationItem));
195 }
196 else
197 {
198 return translationItem;
199 }
200 }
201 catch(FormatException)
202 {
203 return null;
204 }
205 }
206
207 /// <summary>
208 /// Deletes if exists.
209 /// </summary>
210 /// <param name="file">The file.</param>
211 /// <returns></returns>
212 public static bool DeleteIfExists(string file)
213 {
214 string resFile = null;
215 try
216 {
217 resFile = ResolvePath(file);
218 }
219 catch(ArgumentException)
220 {
221 return false;
222 }
223
224 if(!File.Exists(resFile))
225 {
226 return false;
227 }
228
229 File.Delete(resFile);
230 return true;
231 }
232
233 static readonly char seperator = Path.DirectorySeparatorChar;
234
235 // This little gem was taken from the NeL source, thanks guys!
236 /// <summary>
237 /// Makes a relative path
238 /// </summary>
239 /// <param name="startPath">Path to start from</param>
240 /// <param name="endPath">Path to end at</param>
241 /// <returns>Path that will get from startPath to endPath</returns>
242 public static string MakePathRelativeTo(string startPath, string endPath)
243 {
244 string tmp = NormalizePath(startPath, seperator);
245 string src = NormalizePath(endPath, seperator);
246 string prefix = "";
247
248 while(true)
249 {
250 if((String.Compare(tmp, 0, src, 0, tmp.Length) == 0))
251 {
252 string ret;
253 int size = tmp.Length;
254 if(size == src.Length)
255 {
256 return "./";
257 }
258 if((src.Length > tmp.Length) && src[tmp.Length - 1] != seperator)
259 {
260 }
261 else
262 {
263 ret = prefix + endPath.Substring(size, endPath.Length - size);
264 ret = ret.Trim();
265 if(ret[0] == seperator)
266 {
267 ret = "." + ret;
268 }
269
270 return NormalizePath(ret);
271 }
272
273 }
274
275 if(tmp.Length < 2)
276 {
277 break;
278 }
279
280 int lastPos = tmp.LastIndexOf(seperator, tmp.Length - 2);
281 int prevPos = tmp.IndexOf(seperator);
282
283 if((lastPos == prevPos) || (lastPos == -1))
284 {
285 break;
286 }
287
288 tmp = tmp.Substring(0, lastPos + 1);
289 prefix += ".." + seperator.ToString();
290 }
291
292 return endPath;
293 }
294
295 /// <summary>
296 /// Resolves the path.
297 /// </summary>
298 /// <param name="path">The path.</param>
299 /// <returns></returns>
300 public static string ResolvePath(string path)
301 {
302 string tmpPath = NormalizePath(path);
303 if(tmpPath.Length < 1)
304 {
305 tmpPath = ".";
306 }
307
308 tmpPath = Path.GetFullPath(tmpPath);
309 if(!File.Exists(tmpPath) && !Directory.Exists(tmpPath))
310 {
311 throw new ArgumentException("Path could not be resolved: " + tmpPath);
312 }
313
314 return tmpPath;
315 }
316
317 /// <summary>
318 /// Normalizes the path.
319 /// </summary>
320 /// <param name="path">The path.</param>
321 /// <param name="separatorCharacter">The separator character.</param>
322 /// <returns></returns>
323 public static string NormalizePath(string path, char separatorCharacter)
324 {
325 if(path == null || path == "" || path.Length < 1)
326 {
327 return "";
328 }
329
330 string tmpPath = path.Replace('\\', '/');
331 tmpPath = tmpPath.Replace('/', separatorCharacter);
332 return tmpPath;
333 }
334
335 /// <summary>
336 /// Normalizes the path.
337 /// </summary>
338 /// <param name="path">The path.</param>
339 /// <returns></returns>
340 public static string NormalizePath(string path)
341 {
342 return NormalizePath(path, Path.DirectorySeparatorChar);
343 }
344
345 /// <summary>
346 /// Ends the path.
347 /// </summary>
348 /// <param name="path">The path.</param>
349 /// <param name="separatorCharacter">The separator character.</param>
350 /// <returns></returns>
351 public static string EndPath(string path, char separatorCharacter)
352 {
353 if(path == null || path == "" || path.Length < 1)
354 {
355 return "";
356 }
357
358 if(!path.EndsWith(separatorCharacter.ToString()))
359 {
360 return (path + separatorCharacter);
361 }
362
363 return path;
364 }
365
366 /// <summary>
367 /// Ends the path.
368 /// </summary>
369 /// <param name="path">The path.</param>
370 /// <returns></returns>
371 public static string EndPath(string path)
372 {
373 return EndPath(path, Path.DirectorySeparatorChar);
374 }
375
376 /// <summary>
377 /// Makes the file path.
378 /// </summary>
379 /// <param name="path">The path.</param>
380 /// <param name="name">The name.</param>
381 /// <param name="ext">The ext.</param>
382 /// <returns></returns>
383 public static string MakeFilePath(string path, string name, string ext)
384 {
385 string ret = EndPath(NormalizePath(path));
386
387 if( name == null )
388 {
389 throw new ArgumentNullException("name");
390 }
391
392 ret += name;
393 if(!name.EndsWith("." + ext))
394 {
395 ret += "." + ext;
396 }
397
398 //foreach(char c in Path.GetInvalidPathChars())
399 //{
400 // ret = ret.Replace(c, '_');
401 //}
402
403 return ret;
404 }
405
406 /// <summary>
407 /// Makes the file path.
408 /// </summary>
409 /// <param name="path">The path.</param>
410 /// <param name="name">The name.</param>
411 /// <returns></returns>
412 public static string MakeFilePath(string path, string name)
413 {
414 string ret = EndPath(NormalizePath(path));
415
416 if( name == null )
417 {
418 throw new ArgumentNullException("name");
419 }
420
421 ret += name;
422
423 //foreach (char c in Path.GetInvalidPathChars())
424 //{
425 // ret = ret.Replace(c, '_');
426 //}
427
428 return ret;
429 }
430
431 /// <summary>
432 ///
433 /// </summary>
434 /// <param name="path"></param>
435 /// <returns></returns>
436 public static string MakeReferencePath(string path)
437 {
438 string ret = EndPath(NormalizePath(path));
439
440 //foreach (char c in Path.GetInvalidPathChars())
441 //{
442 // ret = ret.Replace(c, '_');
443 //}
444
445 return ret;
446 }
447
448 /// <summary>
449 /// Sets the current dir.
450 /// </summary>
451 /// <param name="path">The path.</param>
452 public static void SetCurrentDir(string path)
453 {
454 if( path == null )
455 {
456 throw new ArgumentNullException("path");
457 }
458 if(path.Length < 1)
459 {
460 return;
461 }
462
463 Environment.CurrentDirectory = path;
464 }
465
466 /// <summary>
467 /// Checks the type.
468 /// </summary>
469 /// <param name="typeToCheck">The type to check.</param>
470 /// <param name="attr">The attr.</param>
471 /// <param name="inter">The inter.</param>
472 /// <returns></returns>
473 public static object CheckType(Type typeToCheck, Type attr, Type inter)
474 {
475 if(typeToCheck == null || attr == null)
476 {
477 return null;
478 }
479
480 object[] attrs = typeToCheck.GetCustomAttributes(attr, false);
481 if(attrs == null || attrs.Length < 1)
482 {
483 return null;
484 }
485 if( inter == null )
486 {
487 throw new ArgumentNullException("inter");
488 }
489
490 if(typeToCheck.GetInterface(inter.FullName) == null)
491 {
492 return null;
493 }
494
495 return attrs[0];
496 }
497
498 /// <summary>
499 /// Attributes the value.
500 /// </summary>
501 /// <param name="node">The node.</param>
502 /// <param name="attr">The attr.</param>
503 /// <param name="def">The def.</param>
504 /// <returns></returns>
505 public static string AttributeValue(XmlNode node, string attr, string def)
506 {
507 if( node == null )
508 {
509 throw new ArgumentNullException("node");
510 }
511 if(node.Attributes[attr] == null)
512 {
513 return def;
514 }
515 string val = node.Attributes[attr].Value;
516 if(!CheckForOSVariables)
517 {
518 return val;
519 }
520
521 return InterpolateForEnvironmentVariables(val);
522 }
523
524 /// <summary>
525 /// Parses the boolean.
526 /// </summary>
527 /// <param name="node">The node.</param>
528 /// <param name="attr">The attr.</param>
529 /// <param name="defaultValue">if set to <c>true</c> [default value].</param>
530 /// <returns></returns>
531 public static bool ParseBoolean(XmlNode node, string attr, bool defaultValue)
532 {
533 if( node == null )
534 {
535 throw new ArgumentNullException("node");
536 }
537 if(node.Attributes[attr] == null)
538 {
539 return defaultValue;
540 }
541 return bool.Parse(node.Attributes[attr].Value);
542 }
543
544 /// <summary>
545 /// Enums the attribute value.
546 /// </summary>
547 /// <param name="node">The node.</param>
548 /// <param name="attr">The attr.</param>
549 /// <param name="enumType">Type of the enum.</param>
550 /// <param name="def">The def.</param>
551 /// <returns></returns>
552 public static object EnumAttributeValue(XmlNode node, string attr, Type enumType, object def)
553 {
554 if( def == null )
555 {
556 throw new ArgumentNullException("def");
557 }
558 string val = AttributeValue(node, attr, def.ToString());
559 return Enum.Parse(enumType, val, true);
560 }
561
562 /// <summary>
563 ///
564 /// </summary>
565 /// <param name="assemblyName"></param>
566 /// <param name="projectType"></param>
567 /// <returns></returns>
568 public static string AssemblyFullName(string assemblyName, ProjectType projectType)
569 {
570 return assemblyName + (projectType == ProjectType.Library ? ".dll" : ".exe");
571 }
572
573 #endregion
574 }
575}
diff --git a/Prebuild/src/Core/Utilities/Log.cs b/Prebuild/src/Core/Utilities/Log.cs
new file mode 100644
index 0000000..4df3def
--- /dev/null
+++ b/Prebuild/src/Core/Utilities/Log.cs
@@ -0,0 +1,276 @@
1#region BSD License
2/*
3Copyright (c) 2004-2005 Matthew Holmes (matthew@wildfiregames.com), Dan Moorehead (dan05a@gmail.com)
4
5Redistribution and use in source and binary forms, with or without modification, are permitted
6provided 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
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
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
20OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
22IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23*/
24#endregion
25
26using System;
27using System.IO;
28
29namespace Prebuild.Core.Utilities
30{
31 /// <summary>
32 ///
33 /// </summary>
34 public enum LogType
35 {
36 /// <summary>
37 ///
38 /// </summary>
39 None,
40 /// <summary>
41 ///
42 /// </summary>
43 Info,
44 /// <summary>
45 ///
46 /// </summary>
47 Warning,
48 /// <summary>
49 ///
50 /// </summary>
51 Error
52 }
53
54 /// <summary>
55 ///
56 /// </summary>
57 [Flags]
58 public enum LogTargets
59 {
60 /// <summary>
61 ///
62 /// </summary>
63 None = 0,
64 /// <summary>
65 ///
66 /// </summary>
67 Null = 1,
68 /// <summary>
69 ///
70 /// </summary>
71 File = 2,
72 /// <summary>
73 ///
74 /// </summary>
75 Console = 4
76 }
77
78 /// <summary>
79 /// Summary description for Log.
80 /// </summary>
81 public class Log : IDisposable
82 {
83 #region Fields
84
85 private TextWriter m_Writer;
86 private LogTargets m_Target = LogTargets.Null;
87 bool disposed;
88
89 #endregion
90
91 #region Constructors
92
93 /// <summary>
94 /// Initializes a new instance of the <see cref="Log"/> class.
95 /// </summary>
96 /// <param name="target">The target.</param>
97 /// <param name="fileName">Name of the file.</param>
98 public Log(LogTargets target, string fileName)
99 {
100 m_Target = target;
101
102 if ((m_Target & LogTargets.File) != 0)
103 {
104 m_Writer = new StreamWriter(fileName, false);
105 }
106 else if ((m_Target & LogTargets.Console) != 0)
107 {
108 // Prevents null reference exceptions when outputing to the log file.
109 // This seems to only happen when running on a network drive.
110 m_Writer = Console.Out;
111 }
112 }
113
114 #endregion
115
116 #region Public Methods
117
118 /// <summary>
119 /// Writes this instance.
120 /// </summary>
121 public void Write()
122 {
123 Write(string.Empty);
124 }
125
126 /// <summary>
127 /// Writes the specified MSG.
128 /// </summary>
129 /// <param name="msg">The MSG.</param>
130 public void Write(string msg)
131 {
132 if((m_Target & LogTargets.Null) != 0)
133 {
134 return;
135 }
136
137 if((m_Target & LogTargets.Console) != 0)
138 {
139 Console.WriteLine(msg);
140 }
141 if((m_Target & LogTargets.File) != 0 && m_Writer != null)
142 {
143 m_Writer.WriteLine(msg);
144 }
145 }
146
147 /// <summary>
148 /// Writes the specified format.
149 /// </summary>
150 /// <param name="format">The format.</param>
151 /// <param name="args">The args.</param>
152 public void Write(string format, params object[] args)
153 {
154 Write(string.Format(format,args));
155 }
156
157 /// <summary>
158 /// Writes the specified type.
159 /// </summary>
160 /// <param name="type">The type.</param>
161 /// <param name="format">The format.</param>
162 /// <param name="args">The args.</param>
163 public void Write(LogType type, string format, params object[] args)
164 {
165 if((m_Target & LogTargets.Null) != 0)
166 {
167 return;
168 }
169
170 string str = "";
171 switch(type)
172 {
173 case LogType.Info:
174 str = "[I] ";
175 break;
176 case LogType.Warning:
177 str = "[!] ";
178 break;
179 case LogType.Error:
180 str = "[X] ";
181 break;
182 }
183
184 Write(str + format,args);
185 }
186
187 /// <summary>
188 /// Writes the exception.
189 /// </summary>
190 /// <param name="type">The type.</param>
191 /// <param name="ex">The ex.</param>
192 public void WriteException(LogType type, Exception ex)
193 {
194 if(ex != null)
195 {
196 Write(type, ex.Message);
197 //#if DEBUG
198 m_Writer.WriteLine("Exception @{0} stack trace [[", ex.TargetSite.Name);
199 m_Writer.WriteLine(ex.StackTrace);
200 m_Writer.WriteLine("]]");
201 //#endif
202 }
203 }
204
205 /// <summary>
206 /// Flushes this instance.
207 /// </summary>
208 public void Flush()
209 {
210 if(m_Writer != null)
211 {
212 m_Writer.Flush();
213 }
214 }
215
216 #endregion
217
218 #region IDisposable Members
219
220 /// <summary>
221 /// Performs application-defined tasks associated with freeing, releasing, or
222 /// resetting unmanaged resources.
223 /// </summary>
224 public void Dispose()
225 {
226 Dispose(true);
227 GC.SuppressFinalize(this);
228 }
229
230 /// <summary>
231 /// Dispose objects
232 /// </summary>
233 /// <param name="disposing">
234 /// If true, it will dispose close the handle
235 /// </param>
236 /// <remarks>
237 /// Will dispose managed and unmanaged resources.
238 /// </remarks>
239 protected virtual void Dispose(bool disposing)
240 {
241 if (!this.disposed)
242 {
243 if (disposing)
244 {
245 if (m_Writer != null)
246 {
247 m_Writer.Close();
248 m_Writer = null;
249 }
250 }
251 }
252 this.disposed = true;
253 }
254
255 /// <summary>
256 ///
257 /// </summary>
258 ~Log()
259 {
260 this.Dispose(false);
261 }
262
263 /// <summary>
264 /// Closes and destroys this object
265 /// </summary>
266 /// <remarks>
267 /// Same as Dispose(true)
268 /// </remarks>
269 public void Close()
270 {
271 Dispose();
272 }
273
274 #endregion
275 }
276}