Updated Home (markdown)

Jonathan Fingold 2018-03-02 09:44:01 -08:00
Родитель dd706f8d8a
Коммит c233590d1a
1 изменённых файлов: 6 добавлений и 4 удалений

10
Home.md

@ -31,6 +31,7 @@ Update the `Startup.cs` file to this:
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Bot.Builder.Adapters; using Microsoft.Bot.Builder.Adapters;
using Microsoft.Bot.Builder.BotFramework;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
@ -59,7 +60,7 @@ namespace Microsoft.Bot.Samples
services.AddSingleton<BotFrameworkAdapter>(_ => services.AddSingleton<BotFrameworkAdapter>(_ =>
{ {
return new BotFrameworkAdapter(Configuration); return new BotFrameworkAdapter(new ConfigurationCredentialProvider(Configuration));
}); });
} }
@ -94,11 +95,11 @@ namespace Microsoft.Bot.Samples
[Route("api/[controller]")] [Route("api/[controller]")]
public class MessagesController : Controller public class MessagesController : Controller
{ {
BotFrameworkAdapter adapter = null; protected readonly BotFrameworkAdapter _adapter;
public MessagesController(BotFrameworkAdapter adapter) public MessagesController(BotFrameworkAdapter adapter)
{ {
this.adapter = adapter; this._adapter = adapter;
} }
public Task OnReceiveActivity(IBotContext context) public Task OnReceiveActivity(IBotContext context)
@ -116,7 +117,8 @@ namespace Microsoft.Bot.Samples
{ {
try try
{ {
await adapter.ProcessActivty(this.Request.Headers["Authorization"].FirstOrDefault(), activity, OnReceiveActivity); await _adapter.ProcessActivity(
this.Request.Headers["Authorization"].FirstOrDefault(), activity, OnReceiveActivity);
return this.Ok(); return this.Ok();
} }
catch (UnauthorizedAccessException) catch (UnauthorizedAccessException)