Merge pull request #900 from Blewzman/FixAggregateExceptionGetBaseException
[mono.git] / mcs / class / System / System.Net / WebUtility.cs
index 90b193f4d8c23becea432e969dc4e063a5174a3e..7aec94896c6c8692be01bfd1cf018191a8f4b31c 100644 (file)
@@ -1,8 +1,10 @@
 //\r
 // System.Net.WebUtility\r
 //\r
-// Author: Mike Kestner  <mkestner@novell.com>\r
+// Authors: Mike Kestner  <mkestner@novell.com>\r
+//          Marek Safar (marek.safar@gmail.com)\r
 //\r
+// Copyright (C) 2014 Xamarin Inc (http://www.xamarin.com)\r
 //\r
 // Permission is hereby granted, free of charge, to any person obtaining\r
 // a copy of this software and associated documentation files (the\r
@@ -37,11 +39,17 @@ namespace System.Net
                \r
                public static string HtmlDecode (string value)\r
                {\r
+                       if (string.IsNullOrEmpty (value))\r
+                               return value;\r
+\r
                        return HttpUtility.HtmlDecode (value);\r
                }\r
                \r
                public static void HtmlDecode (string value, TextWriter output)\r
                {\r
+                       if (output == null)\r
+                               throw new ArgumentNullException ("output");\r
+\r
                        output.Write (HtmlDecode (value));\r
                }\r
                \r
@@ -52,8 +60,33 @@ namespace System.Net
                \r
                public static void HtmlEncode (string value, TextWriter output)\r
                {\r
+                       if (output == null)\r
+                               throw new ArgumentNullException ("output");\r
+\r
                        output.Write (HtmlEncode (value));\r
                }\r
+               \r
+               public static string UrlDecode (string encodedValue)\r
+               {\r
+                       return HttpUtility.UrlDecode (encodedValue);\r
+               }\r
+               \r
+               public static byte[] UrlDecodeToBytes (\r
+                       byte[] encodedValue, int offset, int count)\r
+               {\r
+                       return HttpUtility.UrlDecodeToBytes (encodedValue, offset, count);\r
+               }\r
+               \r
+               public static string UrlEncode (string value)\r
+               {\r
+                       return HttpUtility.UrlEncode (value);\r
+               }\r
+               \r
+               public static byte[] UrlEncodeToBytes (\r
+                       byte[] value, int offset, int count)\r
+               {\r
+                       return HttpUtility.UrlEncodeToBytes (value, offset, count);\r
+               }\r
        }\r
 }\r
 #endif\r