Esempio n. 1
0
 private void OnBubbleEvent(BubbleEvent e)
 {
     if (_isFading)
     {
         return;
     }
     ChangeEnvironment(e.environmentIndex, e.userData);
 }
Esempio n. 2
0
        /// <summary>
        /// Called when the dialog is started and pushed onto the dialog stack.
        /// </summary>
        /// <param name="dc">The <see cref="DialogContext"/> for the current turn of conversation.</param>
        /// <param name="options">Optional, initial information to pass to the dialog.</param>
        /// <param name="cancellationToken">A cancellation token that can be used by other objects
        /// or threads to receive notice of cancellation.</param>
        /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
        public override async Task <DialogTurnResult> BeginDialogAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (options is CancellationToken)
            {
                throw new ArgumentException($"{nameof(options)} cannot be a cancellation token");
            }

            if (Disabled != null && Disabled.GetValue(dc.State))
            {
                return(await dc.EndDialogAsync(cancellationToken : cancellationToken).ConfigureAwait(false));
            }

            bool   handled;
            var    eventName   = EventName?.GetValue(dc.State);
            var    bubbleEvent = BubbleEvent.GetValue(dc.State);
            object value       = null;

            if (EventValue != null)
            {
                value = this.EventValue.GetValue(dc.State);
            }

            if (dc.Parent != null)
            {
                handled = await dc.Parent.EmitEventAsync(eventName, value, bubbleEvent, false, cancellationToken).ConfigureAwait(false);
            }
            else
            {
                handled = await dc.EmitEventAsync(eventName, value, bubbleEvent, false, cancellationToken).ConfigureAwait(false);
            }

            // Save results of operation
            var handledProperty = HandledProperty?.GetValue(dc.State) ?? null;

            if (!string.IsNullOrEmpty(handledProperty))
            {
                dc.State.SetValue(handledProperty, handled);
            }

            return(await dc.EndDialogAsync(handled, cancellationToken).ConfigureAwait(false));
        }