Ejemplo n.º 1
0
        public void choices_must_be_two_or_more()
        {
            var           sut     = new ChoiceOptions();
            List <string> optoins = new List <string> {
                "A"
            };

            Assert.Throws <ArgumentOutOfRangeException>(() => sut.Choices = optoins);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Method which renders the prompt to the user given the current input state.
        /// </summary>
        /// <param name="dc">The <see cref="DialogContext"/> for the current turn of conversation.</param>
        /// <param name="state">Dialog <see cref="InputState"/>.</param>
        /// <param name="cancellationToken">Optional, the <see cref="CancellationToken"/> that can be used by other objects or threads to receive notice of cancellation.</param>
        /// <returns>Activity to send to the user.</returns>
        protected override async Task <IActivity> OnRenderPromptAsync(DialogContext dc, InputState state, CancellationToken cancellationToken = default)
        {
            var locale = DetermineCulture(dc);
            var prompt = await base.OnRenderPromptAsync(dc, state, cancellationToken).ConfigureAwait(false);

            var channelId     = dc.Context.Activity.ChannelId;
            var choiceOptions = ChoiceOptions?.GetValue(dc.State) ?? DefaultChoiceOptions[locale];
            var options       = dc.State.GetValue <ChoiceInputOptions>(ThisPath.Options);

            return(AppendChoices(prompt.AsMessageActivity(), channelId, options.Choices, Style.GetValue(dc.State), choiceOptions));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Method which renders the prompt to the user given the current input state.
        /// </summary>
        /// <param name="dc">The <see cref="DialogContext"/> for the current turn of conversation.</param>
        /// <param name="state">Dialog <see cref="InputState"/>.</param>
        /// <param name="cancellationToken">Optional, the <see cref="CancellationToken"/> that can be used by other objects or threads to receive notice of cancellation.</param>
        /// <returns>Activity to send to the user.</returns>
        protected override async Task <IActivity> OnRenderPromptAsync(DialogContext dc, InputState state, CancellationToken cancellationToken = default)
        {
            var locale = DetermineCulture(dc);
            var prompt = await base.OnRenderPromptAsync(dc, state, cancellationToken).ConfigureAwait(false);

            var channelId     = dc.Context.Activity.ChannelId;
            var choiceOptions = ChoiceOptions?.GetValue(dc.State) ?? DefaultChoiceOptions[locale];

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

            return(AppendChoices(prompt.AsMessageActivity(), channelId, choices, Style.GetValue(dc.State), choiceOptions));
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            ChoiceOptions choiceOptions = new ChoiceOptions();

            choiceOptions.ShowMainMenu();
        }
Ejemplo n.º 5
0
 public Sql(ChoiceOptions choice, string connectionString)
 {
     Choice           = choice;
     ConnectionString = connectionString;
 }
Ejemplo n.º 6
0
 public void AddChoiceOption(ChoiceOption choiceOption)
 {
     ChoiceOptions.Add(choiceOption);
 }