private ComponentDialog CreateDialogStep(ISurveyStepDefinition stepDefinition) { try { var stepBuilder = this.stepBuilders.First(s => s.Matches(stepDefinition)); ComponentDialog step = stepBuilder.Create(stepDefinition); return(step); } catch (Exception ex) { throw new DialogFactoryException($"Could not create ComponentDialog : Unsupported type [{stepDefinition.GetType().FullName}]"); } }
public override ComponentDialog Create(ISurveyStepDefinition step) { try { if (step is FreeTextQuestion questionStep) { return(new FreeTextDialog(questionStep.Id, this.State, this.BotSettings, this.Features) .WithPrompt(questionStep.Prompt) .WithResponses(questionStep.Responses) .WithScore(questionStep.Score) .Build()); } throw new DialogFactoryException($"Could not create {nameof(FreeTextDialog)}, expecting a {nameof(FreeTextQuestion)} definition but was passed a {nameof(step.GetType)}"); } catch (Exception ex) { throw new DialogFactoryException($"Error creating {nameof(FreeTextDialog)}: {ex.Message}", ex); } }
/// <inheritdoc /> public T Create <T>(ISurveyStepDefinition stepDefinition) where T : ComponentDialog => (T)this.CreateDialogStep(stepDefinition);
public abstract ComponentDialog Create(ISurveyStepDefinition stepDefinition);
public bool Matches(ISurveyStepDefinition stepDefinition) { return(stepDefinition is TDefinition); }
public override ComponentDialog Create(ISurveyStepDefinition stepDefinition) { return(new SurveyEndDialog(stepDefinition.Id, this.State, this.BotSettings, this.Features, this.feedbackService) .WithResponses(stepDefinition.Responses) .Build()); }