private static void PartUriDoesntEndWithSlash(Uri uri)
{
var s = !uri.IsAbsoluteUri ? uri.OriginalString
: uri.GetComponents(UriComponents.Path, UriFormat.UriEscaped);
// We allow '/' at uri's beggining.
if ((s.Length > 1) && s.EndsWith("/"))
{
throw new ArgumentException("Part URI cannot end with a forward slash.");
}
}