示例#1
0
        // 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);

            var exchangeSettings = new ExchangeSettings {
                ConnectionUrl = Configuration["EWSConnectionUrl"], ConnectionUserName = Configuration["EWSConnectionUserName"], ConnectionUserPassword = Configuration["EWSConnectionUserPassword"]
            };

            services.AddSingleton(exchangeSettings);

            // Create the Bot Framework Adapter.
            services.AddSingleton <IBotFrameworkHttpAdapter, AdapterWithErrorHandler>();

            // Create the storage we'll be using for User and Conversation state. (Memory is great for testing purposes.)
            var storage = new AzureBlobStorage(Configuration["BlobStorageStateProviderConnectionString"], "bot-state");

            services.AddSingleton <IStorage>(storage);
            //services.AddSingleton<IStorage, MemoryStorage>();

            // Create the User state. (Used in this bot's Dialog implementation.)
            services.AddSingleton <UserState>();

            // Create the Conversation state. (Used by the Dialog system itself.)
            services.AddSingleton <ConversationState>();

            // Register LUIS recognizer
            services.AddSingleton <NotificationOfIllnessRecognizer>();

            // Register the NotificationOfIllnessDialog.
            services.AddSingleton <NotificationOfIllnessDialog>();

            // Register the NotificationOfTeammateDialog.
            services.AddSingleton <NotificationOfTeammateDialog>();

            // The MainDialog that will be run by the bot.
            services.AddSingleton <MainDialog>();

            // Create the bot as a transient. In this case the ASP Controller is expecting an IBot.
            services.AddTransient <IBot, DialogAndWelcomeBot <MainDialog> >();
        }
 public ExchangeMailClient(TokenResponse tokenResponse, ExchangeSettings settings)
 {
     m_ExchangeClient = new ExchangeClient(new Uri(settings.ConnectionUrl), new System.Net.NetworkCredential(settings.ConnectionUserName, settings.ConnectionUserPassword), tokenResponse.GetUPNClaim().Value);
 }