public ActionResult ExtractHighlight([FromBody] string fileName) { List <string> extractedText = new List <string>(); ExtractorFactory factory = new ExtractorFactory(); string filePath = Server.MapPath("../App_Data//Uploads//" + fileName); try { using (WordsTextExtractor extractor = new WordsTextExtractor(filePath)) { IList <string> highlights = extractor.ExtractHighlights( HighlightOptions.CreateFixedLengthOptions(HighlightDirection.Left, 15, 10), HighlightOptions.CreateFixedLengthOptions(HighlightDirection.Right, 20, 10)); for (int i = 0; i < highlights.Count; i++) { extractedText.Add(highlights[i]); } } } catch (Exception ex) { extractedText.Add("File Format not supported"); } return(Json(extractedText, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Returns the formatted text. /// </summary> /// <param name="options">Whatever options were set in the regex groups.</param> /// <param name="text">Send the e.body so it can get formatted.</param> /// <returns>The formatted string of the match.</returns> public string Highlight(HighlightOptions options, string text) { switch (options.Language) { case "c#": CodeFormatter.CSharpFormat csf = new CodeFormatter.CSharpFormat(); csf.LineNumbers = options.DisplayLineNumbers; csf.Alternate = options.AlternateLineNumbers; return csf.FormatCode(text); case "vb": CodeFormatter.VisualBasicFormat vbf = new CodeFormatter.VisualBasicFormat(); vbf.LineNumbers = options.DisplayLineNumbers; vbf.Alternate = options.AlternateLineNumbers; //e.Body = codeRegex.Replace(text, new MatchEvaluator(CodeEvaluator)); //e.Body = codeBeginTagRegex.Replace(codeRegex.Replace(text, new MatchEvaluator(CodeEvaluator)), @"<p>"); //e.Body = codeEndTagRegex.Replace(codeBeginTagRegex.Replace(codeRegex.Replace(text, new MatchEvaluator(CodeEvaluator)), @"<p>"), @"</p>"); return vbf.FormatCode(text); case "js": CodeFormatter.JavaScriptFormat jsf = new CodeFormatter.JavaScriptFormat(); jsf.LineNumbers = options.DisplayLineNumbers; jsf.Alternate = options.AlternateLineNumbers; return jsf.FormatCode(text); case "html": CodeFormatter.HtmlFormat htmlf = new CodeFormatter.HtmlFormat(); htmlf.LineNumbers = options.DisplayLineNumbers; htmlf.Alternate = options.AlternateLineNumbers; text = StripHtml(text).Trim(); string code = htmlf.FormatCode(text).Trim(); return code.Replace(Environment.NewLine, "<br />"); case "xml": CodeFormatter.HtmlFormat xmlf = new CodeFormatter.HtmlFormat(); xmlf.LineNumbers = options.DisplayLineNumbers; xmlf.Alternate = options.AlternateLineNumbers; text = StripHtml(text).Trim(); string xml = xmlf.FormatCode(text).Trim(); return xml.Replace(Environment.NewLine, "<br />"); case "tsql": CodeFormatter.TsqlFormat tsqlf = new CodeFormatter.TsqlFormat(); tsqlf.LineNumbers = options.DisplayLineNumbers; tsqlf.Alternate = options.AlternateLineNumbers; return tsqlf.FormatCode(text); case "msh": CodeFormatter.MshFormat mshf = new CodeFormatter.MshFormat(); mshf.LineNumbers = options.DisplayLineNumbers; mshf.Alternate = options.AlternateLineNumbers; return mshf.FormatCode(text); } return string.Empty; }
/// <summary> /// Returns the formatted text. /// </summary> /// <param name="options">Whatever options were set in the regex groups.</param> /// <param name="text">Send the e.body so it can get formatted.</param> /// <returns>The formatted string of the match.</returns> private string Highlight(HighlightOptions options, string text) { switch (options.Language) { case "c#": CSharpFormat csf = new CSharpFormat(); csf.LineNumbers = options.DisplayLineNumbers; csf.Alternate = options.AlternateLineNumbers; return(HttpContext.Current.Server.HtmlDecode(csf.FormatCode(text))); case "vb": VisualBasicFormat vbf = new VisualBasicFormat(); vbf.LineNumbers = options.DisplayLineNumbers; vbf.Alternate = options.AlternateLineNumbers; return(HttpContext.Current.Server.HtmlDecode(vbf.FormatCode(text))); case "js": JavaScriptFormat jsf = new JavaScriptFormat(); jsf.LineNumbers = options.DisplayLineNumbers; jsf.Alternate = options.AlternateLineNumbers; return(HttpContext.Current.Server.HtmlDecode(jsf.FormatCode(text))); case "html": HtmlFormat htmlf = new HtmlFormat(); htmlf.LineNumbers = options.DisplayLineNumbers; htmlf.Alternate = options.AlternateLineNumbers; text = StripHtml(text).Trim(); string code = htmlf.FormatCode(HttpContext.Current.Server.HtmlDecode(text)).Trim(); return(code.Replace("\r\n", "<br />").Replace("\n", "<br />")); case "xml": HtmlFormat xmlf = new HtmlFormat(); xmlf.LineNumbers = options.DisplayLineNumbers; xmlf.Alternate = options.AlternateLineNumbers; text = text.Replace("<br />", "\r\n"); text = StripHtml(text).Trim(); string xml = xmlf.FormatCode(HttpContext.Current.Server.HtmlDecode(text)).Trim(); return(xml.Replace("\r\n", "<br />").Replace("\n", "<br />")); case "tsql": TsqlFormat tsqlf = new TsqlFormat(); tsqlf.LineNumbers = options.DisplayLineNumbers; tsqlf.Alternate = options.AlternateLineNumbers; return(HttpContext.Current.Server.HtmlDecode(tsqlf.FormatCode(text))); case "msh": MshFormat mshf = new MshFormat(); mshf.LineNumbers = options.DisplayLineNumbers; mshf.Alternate = options.AlternateLineNumbers; return(HttpContext.Current.Server.HtmlDecode(mshf.FormatCode(text))); } return(string.Empty); }
public ContentWriterOptions( OutputDisplayFormat format, GroupDefinition?groupDefinition = null, OutputSymbols symbols = null, HighlightOptions highlightOptions = HighlightOptions.Match | HighlightOptions.Replacement, string indent = null) { Format = format; GroupDefinition = groupDefinition; Symbols = symbols ?? OutputSymbols.Empty; HighlightOptions = highlightOptions; Indent = indent ?? OutputDisplayFormat.DefaultIndent; }
public static bool TryParseHighlightOptions( IEnumerable <string> values, out HighlightOptions highlightOptions, HighlightOptions?defaultValue = null, OptionValueProvider?provider = null) { return(TryParseHighlightOptions( values, out highlightOptions, defaultValue, default(ContentDisplayStyle?), provider)); }
public static bool TryParseHighlightOptions( IEnumerable <string> values, out HighlightOptions highlightOptions, HighlightOptions?defaultValue = null, ContentDisplayStyle?contentDisplayStyle = null, OptionValueProvider?provider = null) { if (contentDisplayStyle == ContentDisplayStyle.Value || contentDisplayStyle == ContentDisplayStyle.ValueDetail) { defaultValue = HighlightOptions.None; } if (values.Any()) { string[] arr = values.ToArray(); for (int i = 0; i < arr.Length; i++) { switch (arr[i]) { case "new-line": { LogHelpers.WriteObsoleteWarning($"Value '{arr[i]}' is obsolete. " + $"Use value '{OptionValues.HighlightOptions_Newline.HelpValue}' instead."); arr[i] = OptionValues.HighlightOptions_Newline.Value; break; } case "nl": { LogHelpers.WriteObsoleteWarning($"Value '{arr[i]}' is obsolete. " + $"Use value '{OptionValues.HighlightOptions_Newline.HelpValue}' instead."); arr[i] = OptionValues.HighlightOptions_Newline.Value; break; } } } values = arr; } return(TryParseAsEnumFlags( values, OptionNames.Highlight, out highlightOptions, defaultValue: defaultValue, provider: provider ?? OptionValueProviders.HighlightOptionsProvider)); }
public static OutputSymbols Create(HighlightOptions options) { if ((options & (HighlightOptions.Character | HighlightOptions.Boundary)) == 0) { return(Empty); } return(new OutputSymbols( tab: ((options & HighlightOptions.Tab) != 0) ? Default.Tab : null, carriageReturn: ((options & HighlightOptions.CarriageReturn) != 0) ? Default.CarriageReturn : null, linefeed: ((options & HighlightOptions.Linefeed) != 0) ? Default.Linefeed : null, space: ((options & HighlightOptions.Space) != 0) ? Default.Space : null, openValue: ((options & HighlightOptions.Boundary) != 0) ? Default.OpenBoundary : null, closeValue: ((options & HighlightOptions.Boundary) != 0) ? Default.CloseBoundary : null)); }
/// <summary> /// /// </summary> /// <param name="match"></param> /// <returns></returns> private string CodeEvaluator(Match match) { if (!match.Success) return match.Value; HighlightOptions options = new HighlightOptions(); options.Language = match.Groups["lang"].Value; options.Code = match.Groups["code"].Value; options.DisplayLineNumbers = match.Groups["linenumbers"].Value == "on" ? true : false; options.Title = match.Groups["title"].Value; options.AlternateLineNumbers = match.Groups["altlinenumbers"].Value == "on" ? true : false; return Highlight(options, match.Value); }
public HighlightWordRule(XElement rule) { // probably need handle rule == null Words = new List <string>(); Options = new HighlightOptions(rule); string wordString = rule.Element("Words").Value; string[] words = Regex.Split(wordString, "\\s+"); foreach (string word in words) { if (!string.IsNullOrWhiteSpace(word)) { Words.Add(word.Trim()); } } }
/// <summary> /// /// </summary> /// <param name="match"></param> /// <returns></returns> private string CodeEvaluator(Match match) { if (!match.Success) return match.Value; HighlightOptions options = new HighlightOptions(); options.Language = match.Groups["lang"].Value; options.Code = match.Groups["code"].Value; options.DisplayLineNumbers = match.Groups["linenumbers"].Value == "on" ? true : false; options.Title = match.Groups["title"].Value; options.AlternateLineNumbers = match.Groups["altlinenumbers"].Value == "on" ? true : false; string result = match.Value.Replace(match.Groups["begin"].Value, ""); result = result.Replace(match.Groups["end"].Value, ""); result = Highlight(options, result); return result; }
/// <summary> /// Code evaluator method /// </summary> /// <param name="match">Match</param> /// <returns>Formatted text</returns> private static string CodeEvaluatorSimple(Match match) { if (!match.Success) { return(match.Value); } var options = new HighlightOptions(); options.Language = "c#"; options.Code = match.Groups["inner"].Value; options.DisplayLineNumbers = false; options.Title = string.Empty; options.AlternateLineNumbers = false; string result = match.Value; result = Highlight(options, result); return(result); }
/// <summary> /// Code evaluator method /// </summary> /// <param name="match">Match</param> /// <returns>Formatted text</returns> private static string CodeEvaluator(Match match) { if (!match.Success) { return(match.Value); } var options = new HighlightOptions(); options.Language = match.Groups["lang"].Value; options.Code = match.Groups["code"].Value; options.DisplayLineNumbers = match.Groups["linenumbers"].Value == "on"; options.Title = match.Groups["title"].Value; options.AlternateLineNumbers = match.Groups["altlinenumbers"].Value == "on"; string result = match.Value.Replace(match.Groups["begin"].Value, ""); result = result.Replace(match.Groups["end"].Value, ""); result = Highlight(options, result); return(result); }
/// <summary> /// Codes the evaluator. /// </summary> /// <param name="match">The match.</param> /// <returns>The code string.</returns> private static string CodeEvaluator(Match match) { if (!match.Success) { return match.Value; } var options = new HighlightOptions { Language = match.Groups["lang"].Value, Code = match.Groups["code"].Value, DisplayLineNumbers = match.Groups["linenumbers"].Value == "on" ? true : false, Title = match.Groups["title"].Value, AlternateLineNumbers = match.Groups["altlinenumbers"].Value == "on" ? true : false }; var result = match.Value.Replace(match.Groups["begin"].Value, string.Empty); result = result.Replace(match.Groups["end"].Value, string.Empty); result = Highlight(options, result); return result; }
/// <summary> /// Codes the evaluator. /// </summary> /// <param name="match">The match.</param> /// <returns>The code string.</returns> private static string CodeEvaluator(Match match) { if (!match.Success) { return(match.Value); } var options = new HighlightOptions { Language = match.Groups["lang"].Value, Code = match.Groups["code"].Value, DisplayLineNumbers = match.Groups["linenumbers"].Value == "on" ? true : false, Title = match.Groups["title"].Value, AlternateLineNumbers = match.Groups["altlinenumbers"].Value == "on" ? true : false }; var result = match.Value.Replace(match.Groups["begin"].Value, string.Empty); result = result.Replace(match.Groups["end"].Value, string.Empty); result = Highlight(options, result); return(result); }
public static void Run() { // Create an instance of Parser class using (Parser parser = new Parser(Constants.SamplePdf)) { HighlightOptions highlightOptions = new HighlightOptions(15); // Search a keyword: IEnumerable <SearchResult> sr = parser.Search("lorem", new SearchOptions(true, false, false, highlightOptions)); // Check if search is supported if (sr == null) { Console.WriteLine("Search isn't supported"); return; } // Iterate over search results foreach (SearchResult s in sr) { // Print the found text and highlights: Console.WriteLine(string.Format("{0}{1}{2}", s.LeftHighlightItem.Text, s.Text, s.RightHighlightItem.Text)); } } }
/// <summary> /// Returns the formatted text. /// </summary> /// <param name="options"> /// Whatever options were set in the regex groups. /// </param> /// <param name="text"> /// Send the e.body so it can get formatted. /// </param> /// <returns> /// The formatted string of the match. /// </returns> private static string Highlight(HighlightOptions options, string text) { switch (options.Language) { case "c#": var csf = new CSharpFormat { LineNumbers = options.DisplayLineNumbers, Alternate = options.AlternateLineNumbers }; return(HttpContext.Current.Server.HtmlDecode(csf.FormatCode(text))); case "vb": var vbf = new VisualBasicFormat { LineNumbers = options.DisplayLineNumbers, Alternate = options.AlternateLineNumbers }; return(HttpContext.Current.Server.HtmlDecode(vbf.FormatCode(text))); case "js": var jsf = new JavaScriptFormat { LineNumbers = options.DisplayLineNumbers, Alternate = options.AlternateLineNumbers }; return(HttpContext.Current.Server.HtmlDecode(jsf.FormatCode(text))); case "html": var htmlf = new HtmlFormat { LineNumbers = options.DisplayLineNumbers, Alternate = options.AlternateLineNumbers }; text = Utils.StripHtml(text); var code = htmlf.FormatCode(HttpContext.Current.Server.HtmlDecode(text)).Trim(); return(code.Replace("\r\n", "<br />").Replace("\n", "<br />")); case "xml": var xmlf = new HtmlFormat { LineNumbers = options.DisplayLineNumbers, Alternate = options.AlternateLineNumbers }; text = text.Replace("<br />", "\r\n"); text = Utils.StripHtml(text); var xml = xmlf.FormatCode(HttpContext.Current.Server.HtmlDecode(text)).Trim(); return(xml.Replace("\r\n", "<br />").Replace("\n", "<br />")); case "tsql": var tsqlf = new TsqlFormat { LineNumbers = options.DisplayLineNumbers, Alternate = options.AlternateLineNumbers }; return(HttpContext.Current.Server.HtmlDecode(tsqlf.FormatCode(text))); case "msh": var mshf = new MshFormat { LineNumbers = options.DisplayLineNumbers, Alternate = options.AlternateLineNumbers }; return(HttpContext.Current.Server.HtmlDecode(mshf.FormatCode(text))); } return(string.Empty); }
/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { LogMessage(string.Format("Entering {0}.Initialize()", this.ToString())); try { await base.InitializeAsync(cancellationToken, progress).ConfigureAwait(true); LogMessage(string.Format("After {0}'s base.Initialize()", this.ToString())); // Set the ApplicationInfo's main assembly so IsDebugBuild will work correctly. ApplicationInfo.Initialize(Title, this.GetType().Assembly); await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); ScanInfo.GetUserRegistryRoot = () => this.UserRegistryRoot; // Ryan Molden from Microsoft says that GetDialogPage caches the result, so we're going to cache it too. // I've also verified GetDialogPage's caching implementation in VS11 by looking at it with Reflector. // http://social.msdn.microsoft.com/Forums/eu/vsx/thread/303fce01-dfc0-43b3-a578-8b3258c0b83f // From http://msdn.microsoft.com/en-us/library/bb165039.aspx baseConverterOptions = this.GetDialogPage(typeof(BaseConverter.Options)) as BaseConverter.Options; generalOptions = this.GetDialogPage(typeof(Options)) as Options; highlightOptions = this.GetDialogPage(typeof(HighlightOptions)) as HighlightOptions; projectOptions = this.GetDialogPage(typeof(Projects.Options)) as Projects.Options; regionOptions = this.GetDialogPage(typeof(Regions.Options)) as Regions.Options; sortOptions = this.GetDialogPage(typeof(Sort.Options)) as Sort.Options; taskOptions = this.GetDialogPage(typeof(Tasks.Options)) as Tasks.Options; this.processor = new CommandProcessor(this); // Add our command handlers. Commands must exist in the .vsct file. if (await this.GetServiceAsync(typeof(IMenuCommandService)).ConfigureAwait(true) is OleMenuCommandService mcs) { foreach (Command id in Enum.GetValues(typeof(Command))) { CommandID commandId = new(Guids.MeneesVsToolsCommandSet, (int)id); // OleMenuCommand extends the base MenuCommand to add BeforeQueryStatus. // http://msdn.microsoft.com/en-us/library/bb165468.aspx OleMenuCommand menuItem = new(this.Command_Execute, commandId); menuItem.BeforeQueryStatus += this.Command_QueryStatus; mcs.AddCommand(menuItem); } } // To make our font and color formats customizable in non-TextEditor windows, // (e.g., Output) we have to hook some old-school TextManager COM events. this.formatManager = new ClassificationFormatManager(this.ServiceProvider); this.formatManager.UpdateFormats(); // This option requires a restart if changed because the CommentTaskProvider and various // XxxMonitor classes attach to too many events and register too many things to easily // detach/unregister and clean them all up if this is toggled interactively. if (TaskOptions.EnableCommentScans) { this.commentTaskProvider = new CommentTaskProvider(this); } this.buildTimer = new BuildTimer(this); } catch (Exception ex) { LogMessage(string.Format("An unhandled exception occurred in {0}.Initialize().", this.ToString()), ex); throw; } LogMessage(string.Format("Exiting {0}.Initialize()", this.ToString())); }
public HighlightLineRule(XElement rule) { // probably need handle rule == null LineStart = rule.Element("LineStart").Value.Trim(); Options = new HighlightOptions(rule); }
public HighlightRegexRule(XElement rule) { Expression = rule.Element("Expression").Value.Trim(); Options = new HighlightOptions(rule); }
public ExcelExportOptions(string sheetName, string path, HighlightOptions highlightOptions) { SheetName = sheetName; Path = path; HighlightOptions = highlightOptions; }
/// <summary> /// Returns the formatted text. /// </summary> /// <param name="options">Whatever options were set in the regex groups.</param> /// <param name="text">Send the e.body so it can get formatted.</param> /// <returns>The formatted string of the match.</returns> private string Highlight(HighlightOptions options, string text) { switch (options.Language) { case "c#": CSharpFormat csf = new CSharpFormat(); csf.LineNumbers = options.DisplayLineNumbers; csf.Alternate = options.AlternateLineNumbers; return HttpContext.Current.Server.HtmlDecode(csf.FormatCode(text)); case "vb": VisualBasicFormat vbf = new VisualBasicFormat(); vbf.LineNumbers = options.DisplayLineNumbers; vbf.Alternate = options.AlternateLineNumbers; return vbf.FormatCode(text); case "js": JavaScriptFormat jsf = new JavaScriptFormat(); jsf.LineNumbers = options.DisplayLineNumbers; jsf.Alternate = options.AlternateLineNumbers; return HttpContext.Current.Server.HtmlDecode(jsf.FormatCode(text)); case "html": HtmlFormat htmlf = new HtmlFormat(); htmlf.LineNumbers = options.DisplayLineNumbers; htmlf.Alternate = options.AlternateLineNumbers; text = StripHtml(text).Trim(); string code = htmlf.FormatCode(HttpContext.Current.Server.HtmlDecode(text)).Trim(); return code.Replace(Environment.NewLine, "<br />"); case "xml": HtmlFormat xmlf = new HtmlFormat(); xmlf.LineNumbers = options.DisplayLineNumbers; xmlf.Alternate = options.AlternateLineNumbers; text = StripHtml(text).Trim(); string xml = xmlf.FormatCode(HttpContext.Current.Server.HtmlDecode(text)).Trim(); return xml.Replace(Environment.NewLine, "<br />"); case "tsql": TsqlFormat tsqlf = new TsqlFormat(); tsqlf.LineNumbers = options.DisplayLineNumbers; tsqlf.Alternate = options.AlternateLineNumbers; return HttpContext.Current.Server.HtmlDecode(tsqlf.FormatCode(text)); case "msh": MshFormat mshf = new MshFormat(); mshf.LineNumbers = options.DisplayLineNumbers; mshf.Alternate = options.AlternateLineNumbers; return HttpContext.Current.Server.HtmlDecode(mshf.FormatCode(text)); } return string.Empty; }
public OutputWriter(HighlightOptions highlightOptions) { HighlightOptions = highlightOptions; }
public static SummarySearchResult Search(SearchPostedData searchRequest, GlobalConfiguration globalConfiguration) { if (index == null) { return(new SummarySearchResult()); } SearchOptions searchOptions = new SearchOptions(); // Turn on fuzzy search on searchOptions.UseCaseSensitiveSearch = false; var searchQuery = searchRequest.GetQuery(); SearchResult result; foreach (char specialChar in specialCharsList) { if (searchQuery.Contains(specialChar)) { foundSpecialChars.Add(specialChar); } } if (searchQuery.Contains(" ")) { result = index.Search("\"" + searchQuery + "\"", searchOptions); } else if (foundSpecialChars.Count > 0) { foreach (char specialChar in foundSpecialChars) { searchQuery = searchQuery.Replace(specialChar, ' '); } foundSpecialChars.Clear(); result = index.Search("\"" + searchQuery + "\"", searchOptions); } else if (Path.HasExtension(searchQuery)) { searchQuery = searchQuery.Replace(".", " "); result = index.Search("\"" + searchQuery + "\"", searchOptions); } else { result = index.Search(searchQuery, searchOptions); } SummarySearchResult summaryResult = new SummarySearchResult(); List <SearchDocumentResult> foundFiles = new List <SearchDocumentResult>(); HighlightOptions options = new HighlightOptions { TermsBefore = 5, TermsAfter = 5, TermsTotal = 10, }; for (int i = 0; i < result.DocumentCount; i++) { SearchDocumentResult searchDocumentResult = new SearchDocumentResult(); FoundDocument document = result.GetFoundDocument(i); HtmlFragmentHighlighter highlighter = new HtmlFragmentHighlighter(); index.Highlight(document, highlighter, options); FragmentContainer[] fragmentContainers = highlighter.GetResult(); List <string> foundPhrases = new List <string>(); for (int j = 0; j < fragmentContainers.Length; j++) { FragmentContainer container = fragmentContainers[j]; string[] fragments = container.GetFragments(); if (fragments.Length > 0) { for (int k = 0; k < fragments.Length; k++) { foundPhrases.Add(fragments[k].Replace("<br>", string.Empty)); } } } searchDocumentResult.SetGuid(document.DocumentInfo.FilePath); searchDocumentResult.SetName(Path.GetFileName(document.DocumentInfo.FilePath)); searchDocumentResult.SetSize(new FileInfo(document.DocumentInfo.FilePath).Length); searchDocumentResult.SetOccurrences(document.OccurrenceCount); searchDocumentResult.SetFoundPhrases(foundPhrases.ToArray()); foundFiles.Add(searchDocumentResult); } summaryResult.SetFoundFiles(foundFiles.ToArray()); summaryResult.SetTotalOccurences(result.OccurrenceCount); summaryResult.SetTotalFiles(result.DocumentCount); string searchDurationString = result.SearchDuration.ToString(@"ss\.ff"); summaryResult.SetSearchDuration(searchDurationString.Equals("00.00") ? "< 1" : searchDurationString); summaryResult.SetIndexedFiles(Directory.GetFiles(globalConfiguration.GetSearchConfiguration().GetIndexedFilesDirectory(), "*", SearchOption.TopDirectoryOnly).Length); return(summaryResult); }
/// <summary> /// Returns the formatted text. /// </summary> /// <param name="options"> /// Whatever options were set in the regex groups. /// </param> /// <param name="text"> /// Send the e.body so it can get formatted. /// </param> /// <returns> /// The formatted string of the match. /// </returns> private static string Highlight(HighlightOptions options, string text) { switch (options.Language) { case "c#": var csf = new CSharpFormat { LineNumbers = options.DisplayLineNumbers, Alternate = options.AlternateLineNumbers }; return HttpContext.Current.Server.HtmlDecode(csf.FormatCode(text)); case "vb": var vbf = new VisualBasicFormat { LineNumbers = options.DisplayLineNumbers, Alternate = options.AlternateLineNumbers }; return HttpContext.Current.Server.HtmlDecode(vbf.FormatCode(text)); case "js": var jsf = new JavaScriptFormat { LineNumbers = options.DisplayLineNumbers, Alternate = options.AlternateLineNumbers }; return HttpContext.Current.Server.HtmlDecode(jsf.FormatCode(text)); case "html": var htmlf = new HtmlFormat { LineNumbers = options.DisplayLineNumbers, Alternate = options.AlternateLineNumbers }; text = Utils.StripHtml(text); var code = htmlf.FormatCode(HttpContext.Current.Server.HtmlDecode(text)).Trim(); return code.Replace("\r\n", "<br />").Replace("\n", "<br />"); case "xml": var xmlf = new HtmlFormat { LineNumbers = options.DisplayLineNumbers, Alternate = options.AlternateLineNumbers }; text = text.Replace("<br />", "\r\n"); text = Utils.StripHtml(text); var xml = xmlf.FormatCode(HttpContext.Current.Server.HtmlDecode(text)).Trim(); return xml.Replace("\r\n", "<br />").Replace("\n", "<br />"); case "tsql": var tsqlf = new TsqlFormat { LineNumbers = options.DisplayLineNumbers, Alternate = options.AlternateLineNumbers }; return HttpContext.Current.Server.HtmlDecode(tsqlf.FormatCode(text)); case "msh": var mshf = new MshFormat { LineNumbers = options.DisplayLineNumbers, Alternate = options.AlternateLineNumbers }; return HttpContext.Current.Server.HtmlDecode(mshf.FormatCode(text)); } return string.Empty; }