2009-01-28 Bill Holmes <billholmes54@gmail.com>
authorBill Holmes <holmes@mono-cvs.ximian.com>
Wed, 28 Jan 2009 23:22:09 +0000 (23:22 -0000)
committerBill Holmes <holmes@mono-cvs.ximian.com>
Wed, 28 Jan 2009 23:22:09 +0000 (23:22 -0000)
* Uri.cs (IsWellFormedUriString):  Changing IsWellFormedUriString
  to not throw an exception but return false instead.

Contributed under MIT/X11 license.

svn path=/trunk/mcs/; revision=124869

mcs/class/System/System/ChangeLog
mcs/class/System/System/Uri.cs

index 4ed8d464b2a4cb501c60aa16b3b9b8d3cc0fa41d..0610ef0f3f75d7f80a9ab69c8c681585f6fa870c 100644 (file)
@@ -1,3 +1,10 @@
+2009-01-28  Bill Holmes  <billholmes54@gmail.com>
+
+       * Uri.cs (IsWellFormedUriString):  Changing IsWellFormedUriString
+         to not throw an exception but return false instead. 
+
+       Contributed under MIT/X11 license.
+
 2009-15-01  Leeszek Ciesielski <skolima@gmail.com>
 
        * Uri.cs: Use registered UriParser when a custom schema is passed
index 732ef6b9d6875fa14034d937976d9fbceffc5372..7460ca0d01983164ffc8d40264803b6c3e7d9a61 100644 (file)
@@ -1992,8 +1992,18 @@ namespace System {
                {
                        if (uriString == null)
                                return false;
-                       Uri uri = new Uri (uriString, uriKind);
-                       return uri.IsWellFormedOriginalString ();
+
+                       if (uriKind != UriKind.RelativeOrAbsolute &&
+                               uriKind != UriKind.Absolute &&
+                               uriKind != UriKind.Relative) {
+                               string msg = Locale.GetText ("Invalid UriKind value '{0}'.", uriKind);
+                                throw new ArgumentException ("uriKind", msg);
+                       }
+
+                       Uri uri;
+                       if (Uri.TryCreate (uriString, uriKind, out uri))
+                               return uri.IsWellFormedOriginalString ();
+                       return false;
                }
 
                public static bool TryCreate (string uriString, UriKind uriKind, out Uri result)