<PackageReference Include="Azure.Storage.Common" Version="12.25.0" />

UriExtensions

static class UriExtensions
Extension methods used to manipulate URIs.
using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Net; using System.Text; namespace Azure.Storage { internal static class UriExtensions { public static Uri AppendToPath(this Uri uri, string segment) { UriBuilder uriBuilder = new UriBuilder(uri); string path = uriBuilder.Path; string str = (path.Length == 0 || path[path.Length - 1] != '/') ? "/" : ""; segment = segment.Replace("%", "%25"); uriBuilder.Path = uriBuilder.Path + str + segment; return uriBuilder.Uri; } public static IDictionary<string, string> GetQueryParameters(this Uri uri) { Dictionary<string, string> dictionary = new Dictionary<string, string>(); string text = uri.Query ?? ""; if (!string.IsNullOrEmpty(text)) { if (text.StartsWith("?", true, CultureInfo.InvariantCulture)) text = text.Substring(1); string[] array = text.Split(new char[1] { '&' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(new char[1] { '=' }, 2); string key = WebUtility.UrlDecode(array2[0]); if (array2.Length == 1) dictionary.Add(key, null); else dictionary.Add(key, WebUtility.UrlDecode(array2[1])); } } return dictionary; } public static string GetAccountNameFromDomain(this Uri uri, string serviceSubDomain) { return GetAccountNameFromDomain(uri.Host, serviceSubDomain); } public static string GetAccountNameFromDomain(string host, string serviceSubDomain) { int num = host.IndexOf(".", StringComparison.InvariantCulture); if (num >= 0) { if (host.IndexOf(serviceSubDomain, num, StringComparison.InvariantCulture) <= -1) return null; return host.Substring(0, num); } return null; } public static string GetPath(this Uri uri) { if (uri.AbsolutePath[0] != '/') return uri.AbsolutePath; return uri.AbsolutePath.Substring(1); } public static bool IsHostIPEndPointStyle(this Uri uri) { if (string.IsNullOrEmpty(uri.Host) || uri.Host.IndexOf(".", StringComparison.InvariantCulture) < 0 || !IPAddress.TryParse(uri.Host, out IPAddress _)) return Constants.Sas.PathStylePorts.Contains(uri.Port); return true; } internal static void AppendQueryParameter(this StringBuilder sb, string key, string value) { sb.Append((sb.Length > 0) ? "&" : "").Append(key).Append('=') .Append(value); } } }