Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 3
0
 protected string PrintEntity(SeparatorEntity separatorEntity)
 {
     return(string.Empty);
 }