public WordCounter(string text) { countText = HtmlUtils.HTMLToPlainText(text); llWords = new LazyLoader <int>(delegate { return(regexWords.Matches(countText).Count); }); llChars = new LazyLoader <int>(delegate { return(regexChars.Matches(countText).Count); }); llCharsWithoutSpaces = new LazyLoader <int>(delegate { return(regexCharsWithoutSpace.Matches(countText).Count); }); llParagraphs = new LazyLoader <int>(delegate { return(countText.Length == 0 ? 0 : regexParagraph.Matches(countText).Count + 1); }); }
public string ToText() { if (_value == null) { return(null); } switch (_type) { case AtomContentValueType.Text: return(_value); case AtomContentValueType.HTML: case AtomContentValueType.XHTML: return(HtmlUtils.HTMLToPlainText(_value, false)); } throw new InvalidOperationException("Unknown text type: " + _type); }