I am trying to understand the Proactive bot sample, where we create a scope, load the dialog stack, interrupt it in between and execute the interrupted one. Can somebody explain me what are scopes in Dependency Injection. I am new to dependency injection and Autofac in C#.
1) What does DialogModule.BeginLifetimeScope(Conversation.Container do?
2) What does var stack = scope.Resolve<IDialogStack>(); do?
3) What does await stack.PollAsync(CancellationToken.None); do?
4) What does await botData.FlushAsync(CancellationToken.None); do?
// Create a scope that can be used to work with state from bot framework.
using (var scope = DialogModule.BeginLifetimeScope(Conversation.Container, message))
{
var botData = scope.Resolve<IBotData>();
await botData.LoadAsync(CancellationToken.None);
// This is the dialog stack.
var stack = scope.Resolve<IDialogStack>();
// Create the new dialog and add it to the stack.
var dialog =new SurveyDialog();
stack.Call(dialog.Void<object, IMessageActivity>(), null);
await stack.PollAsync(CancellationToken.None);
// Flush the dialog stack back to its state store.
await botData.FlushAsync(CancellationToken.None);
}