public void TestingShorten() { var watch = new Stopwatch(); watch.Start(); var data = new HtmlTestData(); string source = data.HTML1; TagParser = new TagParser(source); string tagname = "p"; var start = false; int count = 0; int countto = 250; var tagender = new TagEnder(); string result = ""; TagParser.DoElement = stuff => { if (stuff.State == State.Name && stuff.Element == tagname) { start = true; } }; TagParser.DoTag = stuff => { tagender.Set(stuff.Tag, stuff.State); }; TagParser.DoText = stuff => { if (start) { count += stuff.Position - stuff.Origin; if (count > countto) { result = stuff.Text.ToString().Substring(0, stuff.Position); TagParser.Stop(); } } }; TagParser.Parse(); watch.Stop(); result = result + tagender.CloseTags(); ReportDetail(result); ReportDetail("Elapsed: " + watch.Elapsed); }