protected override async Task TraceStateAsync(ITurnContext turnContext, CancellationToken cancellationToken) { var session = await FindSessionAsync(turnContext, cancellationToken).ConfigureAwait(false); if (session != null) { var task1 = _userState?.LoadAsync(turnContext, false, cancellationToken) ?? Task.CompletedTask; var task2 = _conversationState?.LoadAsync(turnContext, false, cancellationToken) ?? Task.CompletedTask; await Task.WhenAll(task1, task2).ConfigureAwait(false); var botState = new JObject(); if (_userState != null) { botState.Add("userState", _userState.Get(turnContext)); } if (_conversationState != null) { botState.Add("conversationState", _conversationState.Get(turnContext)); } await InvokeSendAsync(turnContext, session, botState.TraceActivity(), cancellationToken).ConfigureAwait(false); } }
protected override async Task TraceStateAsync(ITurnContext turnContext, CancellationToken cancellationToken) { var session = await FindSessionAsync(turnContext, cancellationToken).ConfigureAwait(false); if (session != null) { var task1 = _userState?.LoadAsync(turnContext, false, cancellationToken) ?? Task.CompletedTask; var task2 = _conversationState?.LoadAsync(turnContext, false, cancellationToken) ?? Task.CompletedTask; await Task.WhenAll(task1, task2).ConfigureAwait(false); var botState = new JObject(); if (_userState != null) { var name = _userState.GetType().Name; var cachedState = turnContext.TurnState.Get <object>(name); var obj = JObject.FromObject(cachedState)["State"]; botState.Add("userState", obj); } if (_conversationState != null) { var name = _conversationState.GetType().Name; var cachedState = turnContext.TurnState.Get <object>(name); var obj = JObject.FromObject(cachedState)["State"]; botState.Add("conversationState", obj); } await InvokeSendAsync(turnContext, session, botState.TraceActivity(), cancellationToken).ConfigureAwait(false); } }