Beispiel #1
0
        protected override Task <IActivity> OnRenderPromptAsync(DialogContext dc, InputState state,
                                                                CancellationToken cancellationToken = new CancellationToken())
        {
            if (Prompt == null)
            {
                Prompt = new StaticActivityTemplate(MessageFactory.Text("Prompt for a NumberWithUnitInput"));
            }

            return(base.OnRenderPromptAsync(dc, state, cancellationToken));
        }
        protected override async Task <IActivity> OnRenderPromptAsync(DialogContext dc, InputState state,
                                                                      CancellationToken cancellationToken = new CancellationToken())
        {
            var cardSettings = await PrepareInputSetting(dc, state, cancellationToken);

            if (cardSettings.ChoiceList == null || cardSettings.ChoiceList.Count <= 0)
            {
                throw new ArgumentException("List of Choices should not be empty");
            }

            var attachment = _multiSelectAdaptiveHandler.CreateAttachment(cardSettings);

            if (attachment == null)
            {
                throw new ArgumentException("Render card has failed");
            }

            var activity = new StaticActivityTemplate((Activity)MessageFactory.Attachment(attachment));

            switch (state)
            {
            case InputState.Invalid:
                InvalidPrompt = activity;
                break;

            case InputState.Unrecognized:
                UnrecognizedPrompt = activity;
                break;

            default:
                Prompt = activity;
                break;
            }

            return(await base.OnRenderPromptAsync(dc, state, cancellationToken));
        }