Example #1
0
 /// <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>
 public Prompter(TemplateBaseAttribute annotation, IForm <T> form, IRecognize <T> recognizer)
 {
     annotation.ApplyDefaults(form.Configuration.DefaultPrompt);
     _annotation = annotation;
     _form       = form;
     _recognizer = recognizer;
 }
Example #2
0
 /// <summary>
 /// Any default values in this template will be overridden by the supplied <see cref="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 (ChoiceStyle == ChoiceStyleOptions.Default)
     {
         ChoiceStyle = defaultTemplate.ChoiceStyle;
     }
     if (FieldCase == CaseNormalization.Default)
     {
         FieldCase = defaultTemplate.FieldCase;
     }
     if (Feedback == FeedbackOptions.Default)
     {
         Feedback = defaultTemplate.Feedback;
     }
     if (ChoiceFormat == null)
     {
         ChoiceFormat = defaultTemplate.ChoiceFormat;
     }
     if (LastSeparator == null)
     {
         LastSeparator = defaultTemplate.LastSeparator;
     }
     if (Separator == null)
     {
         Separator = defaultTemplate.Separator;
     }
     if (ValueCase == CaseNormalization.Default)
     {
         ValueCase = defaultTemplate.ValueCase;
     }
 }
Example #3
0
 /// <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;
     ChoiceStyle   = other.ChoiceStyle;
     FieldCase     = other.FieldCase;
     Feedback      = other.Feedback;
     ChoiceFormat  = other.ChoiceFormat;
     LastSeparator = other.LastSeparator;
     Separator     = other.Separator;
     ValueCase     = other.ValueCase;
 }
Example #4
0
 /// <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;
 }
Example #5
0
 protected TemplateBaseAttribute ProcessTemplate(JToken template, TemplateBaseAttribute attribute)
 {
     attribute.Patterns            = template["Patterns"].ToObject <string[]>();
     attribute.AllowDefault        = ProcessEnum <BoolDefault>(template, "AllowDefault");
     attribute.ChoiceCase          = ProcessEnum <CaseNormalization>(template, "ChoiceCase");
     attribute.ChoiceFormat        = (string)template["ChoiceFormat"];
     attribute.ChoiceLastSeparator = (string)template["ChoiceLastSeparator"];
     attribute.ChoiceParens        = ProcessEnum <BoolDefault>(template, "ChoiceParens");
     attribute.ChoiceSeparator     = (string)template["ChoiceSeparator"];
     attribute.ChoiceStyle         = ProcessEnum <ChoiceStyleOptions>(template, "ChoiceStyle");
     attribute.Feedback            = ProcessEnum <FeedbackOptions>(template, "Feedback");
     attribute.FieldCase           = ProcessEnum <CaseNormalization>(template, "FieldCase");
     attribute.LastSeparator       = (string)template["LastSeparator"];
     attribute.Separator           = (string)template["Separator"];
     attribute.ValueCase           = ProcessEnum <CaseNormalization>(template, "ValueCase");
     return(attribute);
 }