Пример #1
0
        protected void DefineRecognizer()
        {
            if (_recognizer == null)
            {
                if (_type == null || _type.IsEnum)
                {
                    _recognizer = new RecognizeEnumeration <T>(this);
                }
                else if (_type == typeof(bool))
                {
                    _recognizer = new RecognizeBool <T>(this);
                }
                else if (_type == typeof(string))
                {
                    _recognizer = new RecognizeString <T>(this);
                }
                else if (_type.IsIntegral())
                {
                    _recognizer = new RecognizeNumber <T>(this);
                }
                else if (_type.IsDouble())
                {
                    _recognizer = new RecognizeDouble <T>(this);
                }
                else if (_type == typeof(DateTime))
                {
                    _recognizer = new RecognizeDateTime <T>(this);
                }
                else if (_type.IsAttachmentType() || _type.IsAttachmentCollection())
                {
                    _recognizer = new RecognizeAttachment <T>(this, _type.IsAttachmentCollection());
                }
                else if (_type.IsIEnumerable())
                {
                    var elt = _type.GetGenericElementType();
                    if (elt.IsEnum)
                    {
                        _recognizer = new RecognizeEnumeration <T>(this);
                    }
                }
                _buildPrompts = true;
            }

            if (_buildPrompts)
            {
                var template = Template(TemplateUsage.Help);
                _help = new Prompter <T>(template, _form, _recognizer);
                var prompt = _promptDefinition;
                _prompt       = new Prompter <T>(_promptDefinition, _form, _recognizer);
                _buildPrompts = false;
            }
        }
Пример #2
0
 protected void DefineRecognizer()
 {
     if (_recognizer == null)
     {
         if (_type == null || _type.IsEnum)
         {
             _recognizer = new RecognizeEnumeration <T>(this);
         }
         else if (_type == typeof(bool))
         {
             _recognizer = new RecognizeBool <T>(this);
         }
         else if (_type == typeof(string))
         {
             _recognizer = new RecognizeString <T>(this);
         }
         else if (_type.IsIntegral())
         {
             _recognizer = new RecognizeNumber <T>(this, Thread.CurrentThread.CurrentUICulture);
         }
         else if (_type.IsDouble())
         {
             _recognizer = new RecognizeDouble <T>(this, Thread.CurrentThread.CurrentUICulture);
         }
         else if (_type == typeof(DateTime))
         {
             _recognizer = new RecognizeDateTime <T>(this, Thread.CurrentThread.CurrentUICulture);
         }
         else if (_type.IsIEnumerable())
         {
             var elt = _type.GetGenericElementType();
             if (elt.IsEnum)
             {
                 _recognizer = new RecognizeEnumeration <T>(this);
             }
         }
         var template = Template(TemplateUsage.Help);
         _help = new Prompter <T>(template, _form, _recognizer);
         var prompt = _promptDefinition;
         _prompt = new Prompter <T>(_promptDefinition, _form, _recognizer);
     }
 }