static async Task Main(string[] args) { IConfigurationBuilder builder = new ConfigurationBuilder() .AddJsonFile("appsettings.json", true) .AddEnvironmentVariables(); IConfigurationRoot configuration = builder .Build(); SpecGeneratorConfiguration config = new SpecGeneratorConfiguration() { SpecificationName = "SpecGenerator " + Guid.NewGuid().ToString().Substring(0, 8), NumberOfCalculations = 2, NumberOfPolices = 1, DatasetDefinitionId = "1221999", DatasetFilePath = @"C:\Users\danie\Desktop\PE and Sports premium - Dan 3.xlsx", }; ILogger logger = new LoggerConfiguration() .WriteTo.Console() .CreateLogger(); using (StaticHttpClientFactory httpClientFactory = new StaticHttpClientFactory()) { ISpecsApiClient specsApiClient = GenerateSpecsClient(logger, httpClientFactory); IDatasetsApiClient datasetsApiClient = GenerateDatasetsClient(logger, httpClientFactory); ICalculationsApiClient calculationsApiClient = GenerateCalculationsApiClient(logger, httpClientFactory); SpecGenerator generator = new SpecGenerator(specsApiClient, datasetsApiClient, calculationsApiClient, logger); try { await generator.Generate(config); logger.Information("Finished generating specification"); Console.ReadKey(); } catch (Exception ex) { logger.Error(ex, "Exception thrown"); } } }
private static IDatasetsApiClient GenerateDatasetsClient(ILogger logger, StaticHttpClientFactory httpClientFactory) { Func <HttpClient> httpClientFunc = new Func <HttpClient>(() => { HttpClient httpClient = new HttpClient(); httpClient.Timeout = new TimeSpan(0, 10, 0); SetDefaultApiOptions(httpClient, new ApiOptions() { ApiEndpoint = "https://localhost:7004/api/datasets", ApiKey = "Local", }); return(httpClient); }); httpClientFactory.AddClient(HttpClientKeys.Datasets, httpClientFunc); return(new DatasetsApiClient(httpClientFactory, logger)); }