private IPrompt <T> NextClarifyPrompt(T state, FieldStepState stepState, IRecognize <T> recognizer, out Ambiguous clarify) { IPrompt <T> prompter = null; clarify = null; foreach (var clarification in stepState.Clarifications) { if (clarification.Values.Length > 1) { clarify = clarification; break; } } if (clarify != null) { var field = new Field <T>("__clarify__", FieldRole.Value); field.Form = _field.Form; var template = _field.Template(TemplateUsage.Clarify); var helpTemplate = _field.Template(template.AllowNumbers ? TemplateUsage.EnumOneNumberHelp : TemplateUsage.EnumManyNumberHelp); field.SetPrompt(new PromptAttribute(template)); field.ReplaceTemplate(_field.Template(TemplateUsage.Clarify)); field.ReplaceTemplate(helpTemplate); foreach (var value in clarify.Values) { field.AddDescription(value, recognizer.ValueDescription(value)); field.AddTerms(value, recognizer.ValidInputs(value).ToArray()); } var choiceRecognizer = new RecognizeEnumeration <T>(field); prompter = new Prompter <T>(template, _field.Form, choiceRecognizer); } return(prompter); }
private IField <T> ClarifyField(Ambiguous clarify, IRecognize <T> recognizer) { var field = new FieldClarify(_field); foreach (var value in clarify.Values) { var choice = value as Choice; if (choice != null) { field.AddDescription(choice.Value, choice.Description.Description, choice.Description.Image, choice.Description.Message); field.AddTerms(choice.Value, choice.Terms.Alternatives); } else { var desc = recognizer.ValueDescription(value); field.AddDescription(value, desc.Description, desc.Image); field.AddTerms(value, recognizer.ValidInputs(value).ToArray()); } } return(field); }