internal static void ConfigureHttpClient(IServiceProvider serviceProvider, HttpClient client) { // Validate parameters. var sp = serviceProvider ?? throw new ArgumentNullException(nameof(ArgumentNullException)); if (client == null) { throw new ArgumentNullException(nameof(client)); } // Get the configuration. IOptions <ChallongeClientConfiguration> options = sp .GetRequiredService <IOptions <ChallongeClientConfiguration> >(); // Get the config. ChallongeClientConfiguration config = options.Value; // If there is no user agent specified, do nothing. if (string.IsNullOrWhiteSpace(config.UserAgent)) { return; } // Set the user agent. client.DefaultRequestHeaders.Add("User-Agent", config.UserAgent); }
private CloudBlobContainer GetStorageContainerReference() { // Get the configuration. ChallongeClientConfiguration config = _challongeClientConfigurationOptions .Value; // Get the storage account. CloudStorageAccount account = CloudStorageAccount.Parse(CommonServices.ShellServices .ConfigurationRoot.GetConnectionString(config.Storage.ConnectionString)); // Get the client. CloudBlobClient client = account.CreateCloudBlobClient(); // Get the container and return. return(client.GetContainerReference(config.Storage.Container)); }