public StorageUri(Uri primaryUri, Uri secondaryUri) { if (primaryUri != null && secondaryUri != null) { bool flag = CommonUtility.UsePathStyleAddressing(primaryUri); bool flag2 = CommonUtility.UsePathStyleAddressing(secondaryUri); if (!flag && !flag2) { if (primaryUri.PathAndQuery != secondaryUri.PathAndQuery) { throw new ArgumentException("Primary and secondary location URIs in a StorageUri must point to the same resource.", "secondaryUri"); } } else { IEnumerable <string> first = primaryUri.Segments.Skip(flag ? 2 : 0); IEnumerable <string> second = secondaryUri.Segments.Skip(flag2 ? 2 : 0); if (!first.SequenceEqual(second) || primaryUri.Query != secondaryUri.Query) { throw new ArgumentException("Primary and secondary location URIs in a StorageUri must point to the same resource.", "secondaryUri"); } } } PrimaryUri = primaryUri; SecondaryUri = secondaryUri; }
internal static string GetAccountNameFromUri(Uri clientUri, bool?usePathStyleUris) { if (!usePathStyleUris.HasValue) { usePathStyleUris = CommonUtility.UsePathStyleAddressing(clientUri); } string[] array = clientUri.AbsoluteUri.Split(SlashAsSplitOptions, StringSplitOptions.RemoveEmptyEntries); if (usePathStyleUris.Value) { if (array.Length < 3) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Cannot find account information inside Uri '{0}'", new object[1] { clientUri.AbsoluteUri })); } return(array[2]); } if (array.Length < 2) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Cannot find account information inside Uri '{0}'", new object[1] { clientUri.AbsoluteUri })); } int length = array[1].IndexOf(".", StringComparison.Ordinal); return(array[1].Substring(0, length)); }
public CloudTableClient(StorageUri storageUri, StorageCredentials credentials, TableClientConfiguration configuration = null) { StorageUri = storageUri; TableClientConfiguration = (configuration ?? new TableClientConfiguration()); Credentials = (credentials ?? new StorageCredentials()); DefaultRequestOptions = new TableRequestOptions(TableRequestOptions.BaseDefaultRequestOptions) { RetryPolicy = new ExponentialRetry(), ConsistencyLevel = configuration?.CosmosExecutorConfiguration?.ConsistencyLevel }; InitializeExecutor(); UsePathStyleUris = CommonUtility.UsePathStyleAddressing(BaseUri); if (!Credentials.IsSharedKey) { AccountName = NavigationHelper.GetAccountNameFromUri(BaseUri, UsePathStyleUris); } lazyDocumentClient = new Lazy <IDocumentClient>(CreateDocumentClient); lazyHttpClient = new Lazy <HttpClient>(CreateHttpClient); }
internal static string GetContainerNameFromContainerAddress(Uri uri, bool?usePathStyleUris) { if (!usePathStyleUris.HasValue) { usePathStyleUris = CommonUtility.UsePathStyleAddressing(uri); } if (!usePathStyleUris.Value) { return(uri.AbsolutePath.Substring(1)); } string[] array = uri.AbsolutePath.Split(SlashAsSplitOptions); if (array.Length < 3) { throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, "Cannot find account information inside Uri '{0}'", new object[1] { uri.AbsoluteUri })); } return(array[2]); }
internal static Uri GetServiceClientBaseAddress(Uri addressUri, bool?usePathStyleUris) { if (addressUri == null) { return(null); } if (!usePathStyleUris.HasValue) { usePathStyleUris = CommonUtility.UsePathStyleAddressing(addressUri); } Uri uri = new Uri(addressUri.GetComponents(UriComponents.SchemeAndServer, UriFormat.UriEscaped)); if (!usePathStyleUris.Value) { return(uri); } string[] segments = addressUri.Segments; if (segments.Length < 2) { throw new ArgumentException("address", string.Format(CultureInfo.CurrentCulture, "Missing account name information inside path style uri. Path style uris should be of the form http://<IPAddressPlusPort>/<accountName>")); } return(new Uri(uri, segments[1])); }