// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Integration.AspNet.Core; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.PowerVirtualAgents.Samples.RelayBotSample.Bots; namespace Microsoft.PowerVirtualAgents.Samples.RelayBotSample { 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.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); // Create the Bot Framework Adapter with error handling enabled. services.AddSingleton(); // Create the bot as a transient. In this case the ASP Controller is expecting an IBot. services.AddSingleton(); // Create the singleton instance of BotService from appsettings var botService = new BotService(); Configuration.Bind("BotService", (object)botService); services.AddSingleton(botService); // Create the singleton instance of ConversationPool from appsettings var conversationManager = new ConversationManager(); Configuration.Bind("ConversationPool", conversationManager); services.AddSingleton(conversationManager); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } app.UseDefaultFiles(); app.UseStaticFiles(); app.UseMvc(); } } }