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); } }
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); } }
public TextBlock(TextBlockTypes textBlockType, char firstChar) : this(textBlockType) { Builder.Append(firstChar); }
public TextBlock(TextBlockTypes textBlockType, StringBuilder builder) { TextBlockType = textBlockType; Builder = builder; }
public TextBlock(TextBlockTypes textBlockType) { TextBlockType = textBlockType; Builder = new StringBuilder(20); }