Esempio n. 1
0
 /// <summary>
 /// Process an incoming message within the conversation.
 /// </summary>
 /// <remarks>
 /// This method:
 /// 1. Instantiates and composes the required components.
 /// 2. Deserializes the dialog state (the dialog stack and each dialog's state) from the <paramref name="toBot"/> <see cref="IMessageActivity"/>.
 /// 3. Resumes the conversation processes where the dialog suspended to wait for a <see cref="IMessageActivity"/>.
 /// 4. Queues <see cref="IMessageActivity"/>s to be sent to the user.
 /// 5. Serializes the updated dialog state in the messages to be sent to the user.
 ///
 /// The <paramref name="MakeRoot"/> factory method is invoked for new conversations only,
 /// because existing conversations have the dialog stack and state serialized in the <see cref="IMessageActivity"/> data.
 /// </remarks>
 /// <param name="toBot">The message sent to the bot.</param>
 /// <param name="MakeRoot">The factory method to make the root dialog.</param>
 /// <param name="token">The cancellation token.</param>
 /// <returns>A task that represents the message to send inline back to the user.</returns>
 public static async Task SendAsync(Microsoft.Bot.Builder.ITurnContext v4Context, Func <IDialog <object> > MakeRoot, CancellationToken token = default(CancellationToken))
 {
     using (var scope = DialogModule.BeginLifetimeScope(Container, v4Context))
     {
         DialogModule_MakeRoot.Register(scope, MakeRoot);
         await SendAsync(scope, v4Context, token);
     }
 }
        public static ILifetimeScope BeginLifetimeScope(ILifetimeScope scope, Microsoft.Bot.Builder.ITurnContext turnContext)
        {
            var inner = scope.BeginLifetimeScope(LifetimeScopeTag);

            inner.Resolve <Microsoft.Bot.Builder.ITurnContext>(TypedParameter.From(turnContext));
            inner.Resolve <IActivity>(TypedParameter.From((IActivity)turnContext.Activity));
            return(inner);
        }
Esempio n. 3
0
 public V4Bridge_BotToUser(Microsoft.Bot.Builder.ITurnContext context)
 {
     SetField.NotNull(out this.context, nameof(context), context);
 }
Esempio n. 4
0
 public static async Task SendAsync(ILifetimeScope scope, Microsoft.Bot.Builder.ITurnContext v4Context, CancellationToken token = default(CancellationToken))
 {
     var task = scope.Resolve <IPostToBot>();
     await task.PostAsync(v4Context.Activity.AsMessageActivity(), token);
 }
Esempio n. 5
0
        /// <summary>
        /// Resume a conversation and post the data to the dialog waiting.
        /// </summary>
        /// <param name="conversationReference"> The resumption cookie.</param>
        /// <param name="toBot"> The data sent to bot.</param>
        /// <param name="token"> The cancellation token.</param>
        /// <returns> A task that represent the message to send back to the user after resumption of the conversation.</returns>
        public static async Task ResumeAsync(ConversationReference conversationReference, Microsoft.Bot.Builder.ITurnContext v4Context, CancellationToken token = default(CancellationToken))
        {
            using (var scope = DialogModule.BeginLifetimeScope(Container, v4Context))
            {
                Func <IDialog <object> > MakeRoot = () => { throw new InvalidOperationException(); };
                DialogModule_MakeRoot.Register(scope, MakeRoot);

                await SendAsync(scope, v4Context, token);
            }
        }
Esempio n. 6
0
        public static async Task ResumeAsync(ResumptionCookie resumptionCookie, Microsoft.Bot.Builder.ITurnContext v4Context, CancellationToken token = default(CancellationToken))
        {
            var conversationRef = resumptionCookie.ToConversationReference();

            await ResumeAsync(conversationRef, v4Context, token);
        }