/// <summary> /// Construct a prompter. /// </summary> /// <param name="annotation">Annotation describing the \ref patterns and formatting for prompt.</param> /// <param name="form">Current form.</param> /// <param name="recognizer">Recognizer if any.</param> /// <param name="fields">Fields name lookup. (Defaults to forms.)</param> public Prompter(TemplateBaseAttribute annotation, IForm <T> form, IRecognize <T> recognizer, IFields <T> fields = null) { annotation.ApplyDefaults(form.Configuration.DefaultPrompt); _annotation = annotation; _form = form; _fields = fields ?? form.Fields; _recognizer = recognizer; }
/// <summary> /// Any default values in this template will be overridden by the supplied <paramref name="defaultTemplate"/>. /// </summary> /// <param name="defaultTemplate">Default template to use to override default values.</param> public void ApplyDefaults(TemplateBaseAttribute defaultTemplate) { if (AllowDefault == BoolDefault.Default) { AllowDefault = defaultTemplate.AllowDefault; } if (ChoiceCase == CaseNormalization.Default) { ChoiceCase = defaultTemplate.ChoiceCase; } if (ChoiceFormat == null) { ChoiceFormat = defaultTemplate.ChoiceFormat; } if (ChoiceLastSeparator == null) { ChoiceLastSeparator = defaultTemplate.ChoiceLastSeparator; } if (ChoiceParens == BoolDefault.Default) { ChoiceParens = defaultTemplate.ChoiceParens; } if (ChoiceSeparator == null) { ChoiceSeparator = defaultTemplate.ChoiceSeparator; } if (ChoiceStyle == ChoiceStyleOptions.Default) { ChoiceStyle = defaultTemplate.ChoiceStyle; } if (FieldCase == CaseNormalization.Default) { FieldCase = defaultTemplate.FieldCase; } if (Feedback == FeedbackOptions.Default) { Feedback = defaultTemplate.Feedback; } if (LastSeparator == null) { LastSeparator = defaultTemplate.LastSeparator; } if (Separator == null) { Separator = defaultTemplate.Separator; } if (ValueCase == CaseNormalization.Default) { ValueCase = defaultTemplate.ValueCase; } }
/// <summary> /// Initialize from another template. /// </summary> /// <param name="other">The template to copy from.</param> public TemplateBaseAttribute(TemplateBaseAttribute other) { Patterns = other.Patterns; AllowDefault = other.AllowDefault; ChoiceCase = other.ChoiceCase; ChoiceFormat = other.ChoiceFormat; ChoiceLastSeparator = other.ChoiceLastSeparator; ChoiceParens = other.ChoiceParens; ChoiceSeparator = other.ChoiceSeparator; ChoiceStyle = other.ChoiceStyle; FieldCase = other.FieldCase; Feedback = other.Feedback; LastSeparator = other.LastSeparator; Separator = other.Separator; ValueCase = other.ValueCase; }