// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // // Generated with Bot Builder V4 SDK Template for Visual Studio EmptyBot v4.16.0 using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Integration.AspNet.Core; using Microsoft.Bot.Connector.Authentication; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using TranslationBot.Translation.Helpers; using TranslationBot.Translation; namespace TranslationBot { public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddHttpClient().AddControllers().AddNewtonsoftJson(options => { options.SerializerSettings.MaxDepth = HttpHelper.BotMessageSerializerSettings.MaxDepth; }); // Create the Bot Framework Authentication to be used with the Bot Adapter. services.AddSingleton(); // Create the Bot Adapter with error handling enabled. services.AddSingleton(); // Create the Microsoft Translator responsible for making calls to the Cognitive Services translation service services.AddSingleton(); // Create the Direct Line Service services.AddSingleton(); // Create the Bot Servie responsible to be used to generate the DL token services.AddSingleton(); // Create the Translation Middleware that will be added to the middleware pipeline services.AddSingleton(); // Create the storage for User and Conversation state (Memory is for testing purposes) services.AddSingleton(); // Create the User state services.AddSingleton(); // Create the Conversation state services.AddSingleton(); // Create the UserLanguage that will handle the language send through the URL services.AddSingleton(); // Create the bot as a transient. In this case the ASP Controller is expecting an IBot. services.AddTransient(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseDefaultFiles() .UseStaticFiles() .UseWebSockets() .UseRouting() .UseAuthorization() .UseEndpoints(endpoints => { endpoints.MapControllers(); }); // app.UseHttpsRedirection(); } } }