Пример #1
0
        /// <summary>
        /// Method which processes options.
        /// </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>
        /// <returns>modified options.</returns>
        protected override object OnInitializeOptions(DialogContext dc, object options)
        {
            var op = options as ChoiceInputOptions;

            if (op == null || op.Choices == null || op.Choices.Count == 0)
            {
                if (op == null)
                {
                    op = new ChoiceInputOptions();
                }

                op.Choices = GetChoiceSetAsync(dc).GetAwaiter().GetResult();
            }

            return(base.OnInitializeOptions(dc, op));
        }
Пример #2
0
        protected override object OnInitializeOptions(DialogContext dc, object options)
        {
            var op = options as ChoiceInputOptions;

            if (op == null || op.Choices == null || op.Choices.Count == 0)
            {
                if (op == null)
                {
                    op = new ChoiceInputOptions();
                }

                var choices = this.Choices.GetValue(dc.GetState());
                op.Choices = choices;
            }

            return(base.OnInitializeOptions(dc, op));
        }
Пример #3
0
        /// <summary>
        /// Method which processes options.
        /// </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>
        /// <returns>modified options.</returns>
        protected override object OnInitializeOptions(DialogContext dc, object options)
        {
            var op = options as ChoiceInputOptions;

            if (op == null || op.Choices == null || op.Choices.Count == 0)
            {
                if (op == null)
                {
                    op = new ChoiceInputOptions();
                }

                var(choices, error) = this.Choices.TryGetValue(dc.State);
                if (error != null)
                {
                    throw new Exception(error);
                }

                op.Choices = choices;
            }

            return(base.OnInitializeOptions(dc, op));
        }