Skip to content

Instantly share code, notes, and snippets.

@smaglio81
Created June 28, 2020 15:48
Show Gist options
  • Save smaglio81/fb6793f38eacc5367f4856756c522c09 to your computer and use it in GitHub Desktop.
Save smaglio81/fb6793f38eacc5367f4856756c522c09 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using Atlassian.Jira;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace YourProject
{
public static class IServiceCollectionExtensions
{
public static IServiceCollection AddSaEnterpriseAzDPullRequestsWeb(
this IServiceCollection services,
Action<AzDPullRequestOptions> configure = null
)
{
services.TryAddTransient<JiraOAuthDelegatingHandler>();
services.TryAddScoped<IAtlassianOAuthenticator, AtlassianOAuthenticator>();
services.AddHttpClient();
services.TryAddTransient<HttpClient>(s =>
{
var factory = s.GetService<IHttpClientFactory>();
return factory.CreateClient();
});
services.AddHttpClient<IJiraDevInfoHttpClient, JiraDevInfoHttpClient>()
.AddHttpMessageHandler<JiraOAuthDelegatingHandler>();
return services;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment