/// <summary> /// Adds a response handler for send activity operations. /// </summary> /// <param name="handler">The handler to add to the context object.</param> /// <returns>The updated context object.</returns> /// <exception cref="ArgumentNullException"><paramref name="handler"/> is <c>null</c>.</exception> /// <remarks>When the context's <see cref="SendActivityAsync(IActivity, CancellationToken)"/> /// or <see cref="SendActivitiesAsync(IActivity[], CancellationToken)"/> methods are called, /// the adapter calls the registered handlers in the order in which they were /// added to the context object. /// </remarks> public ITurnContext OnSendActivities(SendActivitiesHandler handler) { if (handler == null) { throw new ArgumentNullException(nameof(handler)); } _onSendActivities.Add(handler); return(this); }
private async Task SendActivitiesInternal( List <Activity> activities, IEnumerable <SendActivitiesHandler> sendHandlers, Func <Task> callAtBottom) { if (activities == null) { throw new ArgumentException(nameof(activities)); } if (sendHandlers == null) { throw new ArgumentException(nameof(sendHandlers)); } if (sendHandlers.Count() == 0) // No middleware to run. { if (callAtBottom != null) { await callAtBottom(); } return; } // Default to "No more Middleware after this". async Task next() { // Remove the first item from the list of middleware to call, // so that the next call just has the remaining items to worry about. IEnumerable <SendActivitiesHandler> remaining = sendHandlers.Skip(1); await SendActivitiesInternal(activities, remaining, callAtBottom).ConfigureAwait(false); } // Grab the current middleware, which is the 1st element in the array, and execute it SendActivitiesHandler caller = sendHandlers.First(); await caller(this, activities, next); }
public ITurnContext OnSendActivities(SendActivitiesHandler handler) { return(_adapter.OnSendActivities(handler)); }
public ITurnContext OnSendActivities(SendActivitiesHandler handler) => _innerTurnContext.OnSendActivities(handler);
public ITurnContext OnSendActivities(SendActivitiesHandler handler) { throw new NotImplementedException(); }
public ITurnContext OnSendActivities(SendActivitiesHandler handler) { return(_innerTurnContext.OnSendActivities(handler)); }