public override void FixtureSetUp()
        {
            base.FixtureSetUp();
            SD.Services.AddService(typeof(IWorkbench), MockRepository.GenerateStub<IWorkbench>());

            // Set up SearchOptions required by the BruteForceSearchStrategy.
            SearchOptions.CurrentFindPattern = "foo";
            SearchOptions.MatchCase = false;
            SearchOptions.MatchWholeWord = false;

            // Create the document to be searched.
            var doc = new ReadOnlyDocument("foo");

            var location = MockRepository.GenerateStub<SearchLocation>(SearchOptions.SearchTarget, SearchOptions.LookIn, SearchOptions.LookInFiletypes, SearchOptions.IncludeSubdirectories, null);

            location.Stub(l => l.GenerateFileList()).Return(new[] { new FileName(@"C:\Temp\test.txt") });

            // Search the document.
            var strategy = SearchStrategyFactory.Create(SearchOptions.FindPattern, !SearchOptions.MatchCase, SearchOptions.MatchWholeWord, SearchOptions.SearchMode);
            result = SearchManager.FindNext(strategy, location);
        }
		public static void ShowAsSearchResults(string title, List<Reference> list)
		{
			if (list == null) return;
			List<SearchResultMatch> results = new List<SearchResultMatch>(list.Count);
			TextDocument document = null;
			FileName fileName = null;
			IHighlighter highlighter = null;
			foreach (Reference r in list) {
				var f = new FileName(r.FileName);
				if (document == null || !f.Equals(fileName)) {
					document = new TextDocument(DocumentUtilitites.GetTextSource(ParserService.GetParseableFileContent(r.FileName)));
					fileName = new FileName(r.FileName);
					var def = HighlightingManager.Instance.GetDefinitionByExtension(Path.GetExtension(r.FileName));
					if (def != null)
						highlighter = new DocumentHighlighter(document, def.MainRuleSet);
					else
						highlighter = null;
				}
				var start = document.GetLocation(r.Offset).ToLocation();
				var end = document.GetLocation(r.Offset + r.Length).ToLocation();
				var builder = SearchResultsPad.CreateInlineBuilder(start, end, document, highlighter);
				SearchResultMatch res = new SearchResultMatch(fileName, start, end, r.Offset, r.Length, builder);
				results.Add(res);
			}
			SearchResultsPad.Instance.ShowSearchResults(title, results);
			SearchResultsPad.Instance.BringToFront();
		}
		public static void ShowAsSearchResults(string title, List<Reference> list)
		{
			if (list == null) return;
			List<SearchResultMatch> results = new List<SearchResultMatch>(list.Count);
			foreach (Reference r in list) {
				SearchResultMatch res = new SearchResultMatch(GetDocumentInformation(r.FileName), r.Offset, r.Length);
				results.Add(res);
			}
			SearchResultsPad.Instance.ShowSearchResults(title, results);
			SearchResultsPad.Instance.BringToFront();
		}
		public static void ShowAsSearchResults(string title, List<Reference> list)
		{
			if (list == null) return;
			List<SearchResultMatch> results = new List<SearchResultMatch>(list.Count);
			TextDocument document = null;
			ITextBuffer buffer = null;
			FileName fileName = null;
			ISyntaxHighlighter highlighter = null;
			foreach (Reference r in list) {
				var f = new FileName(r.FileName);
				if (document == null || !f.Equals(fileName)) {
					buffer = ParserService.GetParseableFileContent(r.FileName);
					document = new TextDocument(DocumentUtilitites.GetTextSource(buffer));
					fileName = new FileName(r.FileName);
					highlighter = EditorControlService.Instance.CreateHighlighter(new AvalonEditDocumentAdapter(document, null), fileName);
				}
				var start = document.GetLocation(r.Offset).ToLocation();
				var end = document.GetLocation(r.Offset + r.Length).ToLocation();
				var builder = SearchResultsPad.CreateInlineBuilder(start, end, document, highlighter);
				SearchResultMatch res = new SearchResultMatch(fileName, start, end, r.Offset, r.Length, builder, highlighter.DefaultTextColor);
				results.Add(res);
			}
			SearchResultsPad.Instance.ShowSearchResults(title, results);
			SearchResultsPad.Instance.BringToFront();
		}
		public static void ShowAsSearchResults(string title, List<SearchResultMatch> list)
		{
			if (list == null) return;
			List<SearchResultMatch> results = new List<SearchResultMatch>(list.Count);
			ReadOnlyDocument document = null;
			ITextSource buffer = null;
			FileName fileName = null;
			IHighlighter highlighter = null;
			foreach (SearchResultMatch r in list) {
				if (document == null || fileName != r.FileName) {
					if (highlighter != null) {
						highlighter.Dispose();
					}
					fileName = r.FileName;
					buffer = SD.FileService.GetFileContent(r.FileName);
					document = new ReadOnlyDocument(buffer, r.FileName);
					highlighter = SD.EditorControlService.CreateHighlighter(document);
					highlighter.BeginHighlighting();
				}
				var start = r.StartLocation;
				var end = r.EndLocation;
				var startOffset = document.GetOffset(start);
				var endOffset = document.GetOffset(end);
				var builder = SearchResultsPad.CreateInlineBuilder(start, end, document, highlighter);
				var defaultTextColor = highlighter != null ? highlighter.DefaultTextColor : null;
				SearchResultMatch res = new SearchResultMatch(fileName, start, end, startOffset, endOffset - startOffset, builder, defaultTextColor);
				results.Add(res);
			}
			if (highlighter != null) {
				highlighter.Dispose();
			}
			SearchResultsPad.Instance.ShowSearchResults(title, results);
			SearchResultsPad.Instance.BringToFront();
		}