internal static Uri ToUri(string s) { Uri uri; if ((s == null ? false : s.Length > 0)) { s = XmlConvertExt.TrimString(s); if ((s.Length == 0 ? true : s.IndexOf("##", StringComparison.Ordinal) != -1)) { throw new FormatException(); } } if (!Uri.TryCreate(s, UriKind.RelativeOrAbsolute, out uri)) { throw new FormatException(); } return(uri); }
internal static Exception TryToUri(string s, out Uri result) { Exception formatException; result = null; if ((s == null ? false : s.Length > 0)) { s = XmlConvertExt.TrimString(s); if ((s.Length == 0 ? true : s.IndexOf("##", StringComparison.Ordinal) != -1)) { formatException = new FormatException(); return(formatException); } } if (Uri.TryCreate(s, UriKind.RelativeOrAbsolute, out result)) { formatException = null; } else { formatException = new FormatException(); } return(formatException); }