void VisitElementValue(XElement element, MSBuildLanguageElement resolved) { if (element.IsSelfClosing || !element.IsEnded) { return; } var begin = element.Span.End; int end = begin; if (element.IsClosed && element.FirstChild == null) { end = element.ClosingTag.Span.Start; } else { //HACK: in some cases GetCharAt can throw at the end of the document even with TextDocument.Length check try { for (; end < (TextSource.Length + 1) && TextSource.GetCharAt(end) != '<'; end++) { } } catch { end--; } } var text = TextSource.GetTextBetween(begin, end); VisitElementValue(element, resolved, text, begin); }
private void button4_Click(object sender, EventArgs e) { //string text = "hello\r\nIts me!"; string text = "123456\r\nIts me!\r\n"; TextSource textsource = new TextSource(text.ToCharArray()); char c = textsource.GetCharAt(1, 3); if (c != '3') { } //the text source is immutable! //if we want to make a change //just create a new version of that }