2007-01-28 Marek Sieradzki <marek.sieradzki@gmail.com>
[mono.git] / mcs / class / Microsoft.Build.Engine / Microsoft.Build.BuildEngine / Utilities.cs
index ca3fb4a6dd535c06818204f5b9a899a3032f26cc..e3bb5888807ed0e3337709ad265f3fe0e716495f 100644 (file)
 
 #if NET_2_0
 
-namespace Microsoft.Build.BuildEngine {
-       public class Utilities : ILangSecurityLevelChecker, ICultureStringUtilities {
-               public Utilities ()
-               {
-               }
+using System;
+using System.Collections;
+using System.Text;
 
-               public bool CheckPath (string path, int zone)
+namespace Microsoft.Build.BuildEngine {
+       public static class Utilities {
+       
+               static Hashtable charsToEscape;
+       
+               static Utilities ()
                {
-                       return true;
+                       charsToEscape = new Hashtable ();
+                       
+                       charsToEscape.Add ('$', null);
+                       charsToEscape.Add ('%', null);
+                       charsToEscape.Add ('\'', null);
+                       charsToEscape.Add ('(', null);
+                       charsToEscape.Add (')', null);
+                       charsToEscape.Add ('*', null);
+                       charsToEscape.Add (';', null);
+                       charsToEscape.Add ('?', null);
+                       charsToEscape.Add ('@', null);
                }
-
-               public string[] GetSupportedCultures ()
+       
+               public static string Escape (string unescapedExpression)
                {
-                       return null;
+                       StringBuilder sb = new StringBuilder ();
+                       
+                       foreach (char c in unescapedExpression) {
+                               if (charsToEscape.Contains (c))
+                                       sb.AppendFormat ("%{0:x2}", (int) c);
+                               else
+                                       sb.Append (c);
+                       }
+                       
+                       return sb.ToString ();
                }
-
-               public bool ValidateCulture (string culture)
+               
+               // FIXME: add tests for this
+               internal static string Unescape (string escapedExpression)
                {
-                       return true;
+                       StringBuilder sb = new StringBuilder ();
+                       
+                       int i = 0;
+                       while (i < escapedExpression.Length) {
+                               sb.Append (Uri.HexUnescape (escapedExpression, ref i));
+                       }
+                       
+                       return sb.ToString ();
                }
        }
 }
 
-#endif
\ No newline at end of file
+#endif