internal override IEnumerable <HelpInfo> SearchHelp(HelpRequest helpRequest, bool searchOnlyContent)
        {
            string          pattern           = helpRequest.Target;
            string          iteratorVariable1 = pattern;
            int             iteratorVariable2 = 0;
            WildcardPattern iteratorVariable3 = null;

            if (!searchOnlyContent && !WildcardPattern.ContainsWildcardCharacters(pattern))
            {
                iteratorVariable1 = "*" + iteratorVariable1 + "*";
            }
            if (searchOnlyContent)
            {
                string target = helpRequest.Target;
                if (!WildcardPattern.ContainsWildcardCharacters(helpRequest.Target))
                {
                    target = "*" + target + "*";
                }
                iteratorVariable3 = new WildcardPattern(target, WildcardOptions.IgnoreCase | WildcardOptions.Compiled);
                iteratorVariable1 = "*";
            }
            iteratorVariable1 = iteratorVariable1 + ".help.txt";
            Collection <string> iteratorVariable4 = MUIFileSearcher.SearchFiles(iteratorVariable1, this.GetSearchPaths());

            if (iteratorVariable4 != null)
            {
                foreach (string iteratorVariable5 in iteratorVariable4)
                {
                    if (!this._helpFiles.ContainsKey(iteratorVariable5))
                    {
                        try
                        {
                            this.LoadHelpFile(iteratorVariable5);
                        }
                        catch (IOException exception)
                        {
                            this.ReportHelpFileError(exception, helpRequest.Target, iteratorVariable5);
                        }
                        catch (SecurityException exception2)
                        {
                            this.ReportHelpFileError(exception2, helpRequest.Target, iteratorVariable5);
                        }
                    }
                    HelpFileHelpInfo cache = this.GetCache(iteratorVariable5) as HelpFileHelpInfo;
                    if ((cache != null) && (!searchOnlyContent || cache.MatchPatternInContent(iteratorVariable3)))
                    {
                        iteratorVariable2++;
                        yield return(cache);

                        if ((iteratorVariable2 >= helpRequest.MaxResults) && (helpRequest.MaxResults > 0))
                        {
                            break;
                        }
                    }
                }
            }
        }
        internal override IEnumerable <HelpInfo> SearchHelp(HelpRequest helpRequest, bool searchOnlyContent)
        {
            string target  = helpRequest.Target;
            string pattern = target;
            int    countOfHelpInfoObjectsFound = 0;
            // this will be used only when searchOnlyContent == true
            WildcardPattern wildCardPattern = null;

            if ((!searchOnlyContent) && (!WildcardPattern.ContainsWildcardCharacters(target)))
            {
                // Search all the about conceptual topics. This pattern
                // makes about topics discoverable without actually
                // using the word "about_" as in "get-help while".
                pattern = "*" + pattern + "*";
            }

            if (searchOnlyContent)
            {
                string searchTarget = helpRequest.Target;
                if (!WildcardPattern.ContainsWildcardCharacters(helpRequest.Target))
                {
                    searchTarget = "*" + searchTarget + "*";
                }

                wildCardPattern = WildcardPattern.Get(searchTarget, WildcardOptions.Compiled | WildcardOptions.IgnoreCase);
                // search all about_* topics
                pattern = "*";
            }

            pattern += ".help.txt";

            Collection <String> files = MUIFileSearcher.SearchFiles(pattern, GetExtendedSearchPaths());

            var matchedFilesToRemove = FilterToLatestModuleVersion(files);

            if (files == null)
            {
                yield break;
            }

            foreach (string file in files)
            {
                if (matchedFilesToRemove.Contains(file))
                {
                    continue;
                }

                // Check whether the file is already loaded
                if (!_helpFiles.ContainsKey(file))
                {
                    try
                    {
                        LoadHelpFile(file);
                    }
                    catch (IOException ioException)
                    {
                        ReportHelpFileError(ioException, helpRequest.Target, file);
                    }
                    catch (System.Security.SecurityException securityException)
                    {
                        ReportHelpFileError(securityException, helpRequest.Target, file);
                    }
                }

                HelpFileHelpInfo helpInfo = GetCache(file) as HelpFileHelpInfo;

                if (helpInfo != null)
                {
                    if (searchOnlyContent)
                    {
                        if (!helpInfo.MatchPatternInContent(wildCardPattern))
                        {
                            continue;
                        }
                    }

                    countOfHelpInfoObjectsFound++;
                    yield return(helpInfo);

                    if (countOfHelpInfoObjectsFound >= helpRequest.MaxResults && helpRequest.MaxResults > 0)
                    {
                        yield break;
                    }
                }
            }
        }
Example #3
0
        internal override IEnumerable <HelpInfo> SearchHelp(
            HelpRequest helpRequest,
            bool searchOnlyContent)
        {
            using (HelpFileHelpProvider.tracer.TraceMethod())
            {
                string          target  = helpRequest.Target;
                string          pattern = target;
                int             countOfHelpInfoObjectsFound = 0;
                WildcardPattern wildCardPattern             = (WildcardPattern)null;
                if (!searchOnlyContent && !WildcardPattern.ContainsWildcardCharacters(target))
                {
                    pattern = "*" + pattern + "*";
                }
                if (searchOnlyContent)
                {
                    string pattern1 = helpRequest.Target;
                    if (!WildcardPattern.ContainsWildcardCharacters(helpRequest.Target))
                    {
                        pattern1 = "*" + pattern1 + "*";
                    }
                    wildCardPattern = new WildcardPattern(pattern1, WildcardOptions.Compiled | WildcardOptions.IgnoreCase);
                    pattern         = "*";
                }
                // ISSUE: reference to a compiler-generated field
                this.\u003Cpattern\u003E5__e += ".help.txt";
                Collection <string> files = MUIFileSearcher.SearchFiles(pattern, this.GetSearchPaths());
                if (files != null)
                {
                    foreach (string str in files)
                    {
                        if (!this._helpFiles.ContainsKey((object)str))
                        {
                            try
                            {
                                this.LoadHelpFile(str);
                            }
                            catch (IOException ex)
                            {
                                this.ReportHelpFileError((Exception)ex, helpRequest.Target, str);
                            }
                            catch (SecurityException ex)
                            {
                                this.ReportHelpFileError((Exception)ex, helpRequest.Target, str);
                            }
                        }
                        HelpFileHelpInfo helpInfo = this.GetCache(str) as HelpFileHelpInfo;
                        if (helpInfo != null && (!searchOnlyContent || helpInfo.MatchPatternInContent(wildCardPattern)))
                        {
                            ++countOfHelpInfoObjectsFound;
                            yield return((HelpInfo)helpInfo);

                            if (countOfHelpInfoObjectsFound >= helpRequest.MaxResults && helpRequest.MaxResults > 0)
                            {
                                break;
                            }
                        }
                    }
                }
            }
        }