Imported Upstream version 4.6.0.125

Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-08-03 10:59:49 +00:00
parent a569aebcfd
commit e79aa3c0ed
17047 changed files with 3137615 additions and 392334 deletions

View File

@@ -0,0 +1,42 @@
//-----------------------------------------------------------------------
// <copyright file="UriUtil.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace System.IdentityModel
{
using System;
internal static class UriUtil
{
/// <summary>
/// Determines whether a URI is valid and can be created using the specified UriKind.
/// Uri.TryCreate is used here, which is more lax than Uri.IsWellFormedUriString.
/// The reason we use this function is because IsWellFormedUriString will reject valid URIs if they are IPv6 or require escaping.
/// </summary>
/// <param name="uriString">The string to check.</param>
/// <param name="uriKind">The type of URI (usually UriKind.Absolute)</param>
/// <returns>True if the URI is valid, false otherwise.</returns>
public static bool CanCreateValidUri(string uriString, UriKind uriKind)
{
Uri tempUri;
return TryCreateValidUri(uriString, uriKind, out tempUri);
}
/// <summary>
/// Determines whether a URI is valid and can be created using the specified UriKind.
/// Uri.TryCreate is used here, which is more lax than Uri.IsWellFormedUriString.
/// The reason we use this function is because IsWellFormedUriString will reject valid URIs if they are IPv6 or require escaping.
/// </summary>
/// <param name="uriString">The string to check.</param>
/// <param name="uriKind">The type of URI (usually UriKind.Absolute)</param>
/// <param name="result">An out param representing the created URI</param>
/// <returns>True if the URI is valid, false otherwise.</returns>
public static bool TryCreateValidUri(string uriString, UriKind uriKind, out Uri result)
{
return Uri.TryCreate(uriString, uriKind, out result);
}
}
}