public TwitterService(GitHubActionContext gitHubActionContext) { _credentials = new TwitterCredentials(gitHubActionContext.GetParameter(Parameters.TwitterConsumerId), gitHubActionContext.GetParameter(Parameters.TwitterConsumerSecret), gitHubActionContext.GetParameter(Parameters.TwitterAccessToken), gitHubActionContext.GetParameter(Parameters.TwitterAccessTokenSecret)); }
static async Task Main(string[] args) { GitHubActionContext actionContext = new GitHubActionContext(args); actionContext.LoadParameters(); HandlerRequestContext handlerRequestContext = new HandlerRequestContext(); var serviceProvider = new ServiceCollection() .AddLogging(x => x.AddConsole()) .AddGitHubClient(actionContext) .AddSingleton(actionContext) .AddSingleton(handlerRequestContext) .AddSingleton <IJobApplicationService, JobApplicationService>() .AddSingleton <IEventService, EventService>() .AddSingleton <ITwitterService, TwitterService>() .AddSingleton <IObjectScheduledService, ObjectScheduledService>() .AddSingleton <IIdentityService, IdentityService>() .AddSingleton <IEasyCronService, EasyCronService>() .AddHttpClientServices() .AddMediatR(typeof(Program)) .BuildServiceProvider(); var jobApplicationService = serviceProvider.GetService <IJobApplicationService>(); await jobApplicationService.ExecuteJob(); }
public JobApplicationService(ILoggerFactory loggerFactory, GitHubActionContext gitHubActionContext, HandlerRequestContext handlerRequestContext, IMediator mediator, IObjectScheduledService objectScheduledService, IEasyCronService easyCronService) { _logger = loggerFactory.CreateLogger <JobApplicationService>(); _gitHubActionContext = gitHubActionContext; _handlerRequestContext = handlerRequestContext; _mediator = mediator; _objectScheduledService = objectScheduledService; _easyCronService = easyCronService; }
static void Main(string[] args) { GitHubActionContext actionContext = new GitHubActionContext(args); actionContext.LoadParameters(); string value = actionContext.GetParameter(Parameters.WhoToGreet); Console.WriteLine($"Hello {value}!"); }
public EasyCronService(HttpClient httpclient, GitHubActionContext gitHubActionContext, ILoggerFactory loggerFactory) { _httpClient = httpclient; _logger = loggerFactory.CreateLogger <EasyCronService>(); _easyCronClientSecret = gitHubActionContext.GetParameter(Parameters.EasyCronClientSecret); }
public OcrService(HttpClient httpClient, GitHubActionContext gitHubActionContext) { _httpClient = httpClient; _gitHubActionContext = gitHubActionContext; }
public IdentityService(IHttpClientFactory _httpClientFactory, GitHubActionContext gitHubActionContext, ILoggerFactory loggerFactory) { _httpClient = _httpClientFactory.CreateClient(); _identityClientSecret = gitHubActionContext.GetParameter(Parameters.IdentityClientSecret); _logger = loggerFactory.CreateLogger <IdentityService>(); }
public static IServiceCollection AddGitHubClient(this IServiceCollection services, GitHubActionContext gitHubActionContext) { string token = gitHubActionContext.GetParameter(Parameters.GitHubAccessToken); GitHubClient githubClient = new GitHubClient(new ProductHeaderValue(nameof(LatinoNETOnline))); Credentials basicAuth = new Credentials(token); githubClient.Credentials = basicAuth; services.AddSingleton <IGitHubClient, GitHubClient>(service => githubClient); services.AddSingleton <IGitHubService, GitHubService>(); return(services); }