public void ConfigureServices(IServiceCollection services) { services.Configure <TwitterApiCollection>(Configuration.GetSection("TwitterApiCollection")); services.Configure <TextAnalyticsApiConfig>(Configuration.GetSection("CognitiveServicesConfiguration:TextAnalyticsApiConfig")); services.AddMvc(); var textApiSettings = new TextAnalyticsApiConfig(); Configuration.GetSection("CognitiveServicesConfiguration:TextAnalyticsApiConfig").Bind(textApiSettings); services.AddSingleton(GetTextAnalyticsApi(textApiSettings)); services.AddTransient <IList <AnalysisResult>, List <AnalysisResult> >(); services.AddTransient <IList <MultiLanguageInput>, List <MultiLanguageInput> >(); services.AddTransient <ITextAnalysis, TextAnalysisService>(); services.AddSingleton <ITwitterService, TwitterService>(); }
private TextAnalyticsAPI GetTextAnalyticsApi(TextAnalyticsApiConfig configuration) => new TextAnalyticsAPI() { AzureRegion = configuration.AzureRegion, SubscriptionKey = configuration.SubscriptionKey };