【发布时间】:2020-10-14 14:19:17
【问题描述】:
我在我的机器人中实现了一个基于 Microsoft Bot Framework v4 (c#) 的转录功能。对于存储类型,我使用了 Azure 表存储。一切都按预期工作。从那里我希望机器人严格从应用服务中的配置选项卡获取对存储的访问凭据。
但是在我实现这个之后,它说我的方法不再适合重写了。
protected override async Task OnMessageActivityAsync(IConfiguration configuration, ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
{
// First, we use the dispatch model to determine which cognitive service (LUIS or QnA) to use.
var recognizerResult = await _botServices.Dispatch.RecognizeAsync(turnContext, cancellationToken);
// Top intent tell us which cognitive service to use.
var topIntent = recognizerResult.GetTopScoringIntent();
// Next, we call the dispatcher with the top intent.
await DispatchToTopIntentAsync(configuration, turnContext, topIntent.intent, recognizerResult, cancellationToken);
}
我在 OnMessageActivityAsync 方法中添加配置参数后出现此错误。但我需要那里的参数,因为我在 DispatchToTopIntentAsync 中使用它:
// Suche nach der richtigen KnowledgeBase
private async Task DispatchToTopIntentAsync(IConfiguration configuration, ITurnContext<IMessageActivity> turnContext, string intent, RecognizerResult recognizerResult, CancellationToken cancellationToken)
{
switch (intent)
{
case "q_SEKAI_Allgemein":
await ProcessSEKAI_AllgemeinAsync(configuration, turnContext, cancellationToken);
break;
case "q_SEKAI_HomeOffice":
await ProcessSEKAI_HomeOfficeAsync(configuration, turnContext, cancellationToken);
break;
case "q_SEKAI_MixedReality":
await ProcessSEKAI_MixedRealityAsync(configuration, turnContext, cancellationToken);
break;
default:
// Wird ausgeführt, wenn keine KnowledgeBase gefunden wird
_logger.LogInformation($"Dispatch unrecognized intent: {intent}.");
await TableStorageEintrag(configuration, turnContext, cancellationToken);
break;
}
}
在这一部分中,机器人决定哪个知识库最适合进一步的工作。
但是我该如何解决这个问题?随时询问您是否需要更多信息。然后我会尽快编辑我的帖子:)
(此截图参考了这篇文章的答案)
【问题讨论】:
-
如果
IConfiguration是用户定义的接口,则使用完整的命名空间路径,因为.NET 中有IConfiguration接口,这可能是您的问题的原因。跨度> -
“有没有办法让这个方法适合覆盖?”——那个方法?不可以。覆盖必须具有与原始虚拟方法声明完全相同相同的签名。见重复。还有其他方法可以实现类似的东西吗?也许。取决于你到底想做什么。
标签: c# methods botframework overriding