Example #1
0
        public IEnumerator <TextBlock> GetEnumerator()
        {
            TextBlock      word            = null;
            TextBlockTypes currentCharType = TextBlockTypes.Unknown;

            foreach (char c in Text)
            {
                if ('0' <= c && c <= '9')
                {
                    currentCharType = TextBlockTypes.Numbers;
                }
                else if (SeparatorEntity.IsSeparator(c))
                {
                    currentCharType = TextBlockTypes.Separator;
                }
                else
                {
                    currentCharType = TextBlockTypes.Word;
                }

                if (word == null)
                {
                    word = new TextBlock(currentCharType, c);
                }
                else if (currentCharType == word.TextBlockType)
                {
                    word.Builder.Append(c);
                }

                else
                {
                    if (word.ToString().Trim() != string.Empty)
                    {
                        yield return(word);
                    }
                    word = new TextBlock(currentCharType, c);
                }
            }

            if (word != null && word.ToString().Trim() != string.Empty)
            {
                yield return(word);
            }
        }
Example #2
0
        public IEntity CreateEntity(string word, TextBlockTypes attribute)
        {
            if (word == string.Empty)
            {
                return(null);
            }

            switch (attribute)
            {
            case TextBlockTypes.Numbers:
                return(new IntegerEntity(int.Parse(word)));

            case TextBlockTypes.Separator:
                return(SeparatorEntity.GetSeparator(word.Trim()));

            case TextBlockTypes.Word:
                return(DictionaryManager.GetInstance().Translate(LanguageManager.GetInstance().DeterminateLanguage(word), word));

            default:
                return(null);
            }
        }
Example #3
0
 public TextBlock(TextBlockTypes textBlockType, char firstChar)
     : this(textBlockType)
 {
     Builder.Append(firstChar);
 }
Example #4
0
 public TextBlock(TextBlockTypes textBlockType, StringBuilder builder)
 {
     TextBlockType = textBlockType;
     Builder       = builder;
 }
Example #5
0
 public TextBlock(TextBlockTypes textBlockType)
 {
     TextBlockType = textBlockType;
     Builder       = new StringBuilder(20);
 }