0
リストの値を返してボットエミュレータで表示する必要があります。リストの値をボットダイアログに表示する方法は?
private static Dictionary<string, int> Teams;
上記のリストには、チーム名のすべてのリストが追加されています。
コード:
public int GetTeamCount()
{
return Teams.Count;
}
public List<string> GetTeams()
{
var sorted = Teams.OrderBy(p => p.Value);
List<string> orderedTeams = new List<string>();
foreach (var e in sorted)
{
orderedTeams.Add(e.Key);
}
return orderedTeams;
}
上記のリストには、チーム名のリストを返します。エミュレータではチームのリストを要求し、ボットはすべてのチーム名を返すことができるはずです。
DialogClass.cs:
private async Task ActivityReceivedAsync(IDialogContext context, IAwaitable<object> result)
{
var activity = await result as Activity;
Championships champ = new Championships();
if (activity.Text.Contains("how many teams"))
{
await context.PostAsync($"There are {champ.GetTeamCount()} teams.");
}
else if (activity.Text.Contains("list of team names"))
{
await context.PostAsync($"There are {champ.GetTeams()}");
}
else
{
await context.PostAsync("My responses are limited. Please ask the right questions. ");
}
context.Wait(ActivityReceivedAsync);
}
は、どのように私は次の行に表示されたチーム名のリストを得ることができますか?
await context.PostAsync($"There are {champ.GetTeams()}");