private HelpInfo GetHelpInfoFromHelpFile(PSClassInfo classInfo, string helpFileToFind, Collection <string> searchPaths, bool reportErrors, out string helpFile) { Dbg.Assert(classInfo != null, "Caller should verify that classInfo != null"); Dbg.Assert(helpFileToFind != null, "Caller should verify that helpFileToFind != null"); helpFile = MUIFileSearcher.LocateFile(helpFileToFind, searchPaths); if (!File.Exists(helpFile)) { return(null); } if (!string.IsNullOrEmpty(helpFile)) { // Load the help file only once. Then use it from the cache. if (!_helpFiles.Contains(helpFile)) { LoadHelpFile(helpFile, helpFile, classInfo.Name, reportErrors); } return(GetFromPSClassHelpCache(helpFile, Automation.HelpCategory.Class)); } return(null); }
private static Collection <string> NormalizeSearchPaths( string target, Collection <string> searchPaths) { Collection <string> collection = new Collection <string>(); if (!string.IsNullOrEmpty(target) && !string.IsNullOrEmpty(Path.GetDirectoryName(target))) { string directoryName = Path.GetDirectoryName(target); if (Directory.Exists(directoryName)) { collection.Add(Path.GetFullPath(directoryName)); } return(collection); } if (searchPaths != null) { foreach (string searchPath in searchPaths) { if (!collection.Contains(searchPath) && Directory.Exists(searchPath)) { collection.Add(searchPath); } } } string installationPath = MUIFileSearcher.GetMshDefaultInstallationPath(); if (installationPath != null && !collection.Contains(installationPath) && Directory.Exists(installationPath)) { collection.Add(installationPath); } return(collection); }
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 static string LocateFile(string file, Collection<string> searchPaths) { MUIFileSearcher searcher = new MUIFileSearcher(file, searchPaths, System.Management.Automation.SearchMode.First); if ((searcher.Result != null) && (searcher.Result.Count != 0)) { return searcher.Result[0]; } return null; }
internal static string LocateFile(string file, Collection <string> searchPaths) { MUIFileSearcher searcher = new MUIFileSearcher(file, searchPaths, System.Management.Automation.SearchMode.First); if ((searcher.Result != null) && (searcher.Result.Count != 0)) { return(searcher.Result[0]); } return(null); }
/// <summary> /// Get the file in different search paths corresponding to current culture. /// /// The file name to search is the filename part of path parameter. (Normally path /// parameter should contain only the filename part. But it is possible for /// RunspaceConfiguration to directly specify a hard coded path for help file there). /// /// </summary> /// <param name="file">This is the path to the file. If it has a path, we need to search under that path first</param> /// <param name="searchPaths">Additional search paths</param> /// <returns></returns> internal static string LocateFile(string file, Collection <String> searchPaths) { MUIFileSearcher searcher = new MUIFileSearcher(file, searchPaths, SearchMode.First); if (searcher.Result == null || searcher.Result.Count == 0) { return(null); } return(searcher.Result[0]); }
internal sealed override void LoadCache() { Collection <string> collection = MUIFileSearcher.SearchFiles("*.concept.xml", base.GetSearchPaths()); if (collection != null) { foreach (string str in collection) { if (!this._helpFiles.ContainsKey(str)) { this.LoadHelpFile(str); this._helpFiles[str] = 0; } } } }
internal string GetHelpFile(CommandInfo commandInfo) { if (this.sections.mamlHelpFile == null) { return((string)null); } string file1 = this.sections.mamlHelpFile; Collection <string> searchPaths = new Collection <string>(); string file2 = ((IScriptCommandInfo)commandInfo).ScriptBlock.File; if (!string.IsNullOrEmpty(file2)) { file1 = Path.Combine(Path.GetDirectoryName(file2), this.sections.mamlHelpFile); } return(MUIFileSearcher.LocateFile(file1, searchPaths)); }
internal override IEnumerable <HelpInfo> ExactMatchHelp(HelpRequest helpRequest) { int countHelpInfosFound = 0; string helpFileName = helpRequest.Target + ".help.txt"; Collection <string> filesMatched = MUIFileSearcher.SearchFiles(helpFileName, GetExtendedSearchPaths()); Diagnostics.Assert(filesMatched != null, "Files collection should not be null."); var matchedFilesToRemove = FilterToLatestModuleVersion(filesMatched); foreach (string file in filesMatched) { 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); } } HelpInfo helpInfo = GetCache(file); if (helpInfo != null) { countHelpInfosFound++; yield return(helpInfo); if ((countHelpInfosFound >= helpRequest.MaxResults) && (helpRequest.MaxResults > 0)) { yield break; } } } }
internal override sealed void LoadCache() { Collection <string> collection = MUIFileSearcher.SearchFiles("*.faq.xml", this.GetSearchPaths()); if (collection == null) { return; } foreach (string helpFile in collection) { if (!this._helpFiles.ContainsKey((object)helpFile)) { this.LoadHelpFile(helpFile); this._helpFiles[(object)helpFile] = (object)0; } } }
/// <summary> /// Load cache for faq help's /// </summary> internal sealed override void LoadCache() { Collection <String> files = MUIFileSearcher.SearchFiles("*.faq.xml", GetSearchPaths()); if (files == null) { return; } foreach (string file in files) { if (!_helpFiles.ContainsKey(file)) { LoadHelpFile(file); // Add this file into _helpFiles hashtable to prevent it to be loaded again. _helpFiles[file] = 0; } } }
internal string GetHelpFile(CommandInfo commandInfo) { if (this._sections.MamlHelpFile == null) { return(null); } string mamlHelpFile = this._sections.MamlHelpFile; Collection <string> searchPaths = new Collection <string>(); string file = ((IScriptCommandInfo)commandInfo).ScriptBlock.File; if (!string.IsNullOrEmpty(file)) { mamlHelpFile = Path.Combine(Path.GetDirectoryName(file), this._sections.MamlHelpFile); } else if (commandInfo.Module != null) { mamlHelpFile = Path.Combine(Path.GetDirectoryName(commandInfo.Module.Path), this._sections.MamlHelpFile); } return(MUIFileSearcher.LocateFile(mamlHelpFile, searchPaths)); }
private string FindHelpFile(CmdletInfo cmdletInfo) { if (cmdletInfo == null) { throw PSTraceSource.NewArgumentNullException("cmdletInfo"); } string helpFile = cmdletInfo.HelpFile; if (string.IsNullOrEmpty(helpFile)) { if ((cmdletInfo.Module != null) && InitialSessionState.IsEngineModule(cmdletInfo.Module.Name)) { return(Path.Combine(cmdletInfo.Module.ModuleBase, Thread.CurrentThread.CurrentCulture.Name, engineModuleHelpFileCache[cmdletInfo.Module.Name])); } return(helpFile); } string file = helpFile; PSSnapInInfo pSSnapIn = cmdletInfo.PSSnapIn; Collection <string> searchPaths = new Collection <string>(); if (pSSnapIn != null) { file = Path.Combine(pSSnapIn.ApplicationBase, helpFile); } else if ((cmdletInfo.Module != null) && !string.IsNullOrEmpty(cmdletInfo.Module.Path)) { file = Path.Combine(cmdletInfo.Module.ModuleBase, helpFile); } else { searchPaths.Add(base.GetDefaultShellSearchPath()); searchPaths.Add(GetCmdletAssemblyPath(cmdletInfo)); } string str3 = MUIFileSearcher.LocateFile(file, searchPaths); if (string.IsNullOrEmpty(str3)) { tracer.WriteLine("Unable to load file {0}", new object[] { file }); } return(str3); }
private void SearchForFiles() { if (string.IsNullOrEmpty(this.Target)) { return; } string fileName = Path.GetFileName(this.Target); if (string.IsNullOrEmpty(fileName)) { return; } foreach (string normalizeSearchPath in MUIFileSearcher.NormalizeSearchPaths(this.Target, this.SearchPaths)) { this.SearchForFiles(fileName, normalizeSearchPath); if (this.SearchMode == SearchMode.First && this.Result.Count > 0) { break; } } }
internal override IEnumerable <HelpInfo> ExactMatchHelp( HelpRequest helpRequest) { using (HelpFileHelpProvider.tracer.TraceMethod()) { int countHelpInfosFound = 0; string helpFileName = helpRequest.Target + ".help.txt"; Collection <string> filesMatched = MUIFileSearcher.SearchFiles(helpFileName, this.GetSearchPaths()); foreach (string str in filesMatched) { 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); } } HelpInfo helpInfo = this.GetCache(str); if (helpInfo != null) { ++countHelpInfosFound; yield return(helpInfo); if (countHelpInfosFound >= helpRequest.MaxResults && helpRequest.MaxResults > 0) { break; } } } } }
internal override IEnumerable <HelpInfo> ExactMatchHelp(HelpRequest helpRequest) { int iteratorVariable0 = 0; string pattern = helpRequest.Target + ".help.txt"; Collection <string> iteratorVariable2 = MUIFileSearcher.SearchFiles(pattern, this.GetSearchPaths()); foreach (string iteratorVariable3 in iteratorVariable2) { if (!this._helpFiles.ContainsKey(iteratorVariable3)) { try { this.LoadHelpFile(iteratorVariable3); } catch (IOException exception) { this.ReportHelpFileError(exception, helpRequest.Target, iteratorVariable3); } catch (SecurityException exception2) { this.ReportHelpFileError(exception2, helpRequest.Target, iteratorVariable3); } } HelpInfo cache = this.GetCache(iteratorVariable3); if (cache != null) { iteratorVariable0++; yield return(cache); if ((iteratorVariable0 >= helpRequest.MaxResults) && (helpRequest.MaxResults > 0)) { break; } } } }
internal static string LocateFile(string file) => MUIFileSearcher.LocateFile(file, new Collection <string>());
private void LoadHelpFile(ProviderInfo providerInfo) { using (ProviderHelpProvider.tracer.TraceMethod()) { string str1 = providerInfo != null ? providerInfo.HelpFile : throw ProviderHelpProvider.tracer.NewArgumentNullException(nameof(providerInfo)); if (string.IsNullOrEmpty(str1) || this._helpFiles.Contains((object)str1)) { return; } string file = str1; PSSnapInInfo psSnapIn = providerInfo.PSSnapIn; Collection <string> searchPaths = new Collection <string>(); if (psSnapIn != null) { file = Path.Combine(psSnapIn.ApplicationBase, str1); } else if (providerInfo.Module != null && !string.IsNullOrEmpty(providerInfo.Module.Path)) { file = Path.Combine(providerInfo.Module.ModuleBase, str1); } else { searchPaths.Add(this.GetDefaultShellSearchPath()); searchPaths.Add(ProviderHelpProvider.GetProviderAssemblyPath(providerInfo)); } string str2 = MUIFileSearcher.LocateFile(file, searchPaths); if (string.IsNullOrEmpty(str2)) { throw new FileNotFoundException(str1); } XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(str2); this._helpFiles[(object)str1] = (object)0; XmlNode xmlNode = (XmlNode)null; if (xmlDocument.HasChildNodes) { for (int i = 0; i < xmlDocument.ChildNodes.Count; ++i) { XmlNode childNode = xmlDocument.ChildNodes[i]; if (childNode.NodeType == XmlNodeType.Element && string.Compare(childNode.Name, "helpItems", StringComparison.OrdinalIgnoreCase) == 0) { xmlNode = childNode; break; } } } if (xmlNode == null) { return; } using (this.HelpSystem.Trace(str2)) { if (!xmlNode.HasChildNodes) { return; } for (int i = 0; i < xmlNode.ChildNodes.Count; ++i) { XmlNode childNode = xmlNode.ChildNodes[i]; if (childNode.NodeType == XmlNodeType.Element && string.Compare(childNode.Name, "providerHelp", StringComparison.OrdinalIgnoreCase) == 0) { HelpInfo helpInfo = (HelpInfo)ProviderHelpInfo.Load(childNode); if (helpInfo != null) { this.HelpSystem.TraceErrors(helpInfo.Errors); helpInfo.FullHelp.TypeNames.Insert(0, string.Format((IFormatProvider)CultureInfo.InvariantCulture, "ProviderHelpInfo#{0}#{1}", (object)providerInfo.PSSnapInName, (object)helpInfo.Name)); if (!string.IsNullOrEmpty(providerInfo.PSSnapInName)) { helpInfo.FullHelp.Properties.Add((PSPropertyInfo) new PSNoteProperty("PSSnapIn", (object)providerInfo.PSSnapIn)); helpInfo.FullHelp.TypeNames.Insert(1, string.Format((IFormatProvider)CultureInfo.InvariantCulture, "ProviderHelpInfo#{0}", (object)providerInfo.PSSnapInName)); } this.AddCache(providerInfo.PSSnapInName + "\\" + helpInfo.Name, helpInfo); } } } } } }
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; } } } }
private void LoadHelpFile(ProviderInfo providerInfo) { if (providerInfo == null) { throw PSTraceSource.NewArgumentNullException("providerInfo"); } string helpFile = providerInfo.HelpFile; if (!string.IsNullOrEmpty(helpFile) && !this._helpFiles.Contains(helpFile)) { string file = helpFile; PSSnapInInfo pSSnapIn = providerInfo.PSSnapIn; Collection <string> searchPaths = new Collection <string>(); if (pSSnapIn != null) { file = Path.Combine(pSSnapIn.ApplicationBase, helpFile); } else if ((providerInfo.Module != null) && !string.IsNullOrEmpty(providerInfo.Module.Path)) { file = Path.Combine(providerInfo.Module.ModuleBase, helpFile); } else { searchPaths.Add(base.GetDefaultShellSearchPath()); searchPaths.Add(GetProviderAssemblyPath(providerInfo)); } string str3 = MUIFileSearcher.LocateFile(file, searchPaths); if (string.IsNullOrEmpty(str3)) { throw new FileNotFoundException(helpFile); } XmlDocument document = InternalDeserializer.LoadUnsafeXmlDocument(new FileInfo(str3), false, null); this._helpFiles[helpFile] = 0; System.Xml.XmlNode node = null; if (document.HasChildNodes) { for (int i = 0; i < document.ChildNodes.Count; i++) { System.Xml.XmlNode node2 = document.ChildNodes[i]; if ((node2.NodeType == XmlNodeType.Element) && (string.Compare(node2.Name, "helpItems", StringComparison.OrdinalIgnoreCase) == 0)) { node = node2; break; } } } if (node != null) { using (base.HelpSystem.Trace(str3)) { if (node.HasChildNodes) { for (int j = 0; j < node.ChildNodes.Count; j++) { System.Xml.XmlNode xmlNode = node.ChildNodes[j]; if ((xmlNode.NodeType == XmlNodeType.Element) && (string.Compare(xmlNode.Name, "providerHelp", StringComparison.OrdinalIgnoreCase) == 0)) { HelpInfo helpInfo = ProviderHelpInfo.Load(xmlNode); if (helpInfo != null) { base.HelpSystem.TraceErrors(helpInfo.Errors); helpInfo.FullHelp.TypeNames.Insert(0, string.Format(CultureInfo.InvariantCulture, "ProviderHelpInfo#{0}#{1}", new object[] { providerInfo.PSSnapInName, helpInfo.Name })); if (!string.IsNullOrEmpty(providerInfo.PSSnapInName)) { helpInfo.FullHelp.Properties.Add(new PSNoteProperty("PSSnapIn", providerInfo.PSSnapIn)); helpInfo.FullHelp.TypeNames.Insert(1, string.Format(CultureInfo.InvariantCulture, "ProviderHelpInfo#{0}", new object[] { providerInfo.PSSnapInName })); } base.AddCache(providerInfo.PSSnapInName + @"\" + helpInfo.Name, helpInfo); } } } } } } } }
/// <summary> /// Search for files in specified search paths. /// </summary> /// <param name="pattern"></param> /// <param name="searchPaths"></param> /// <returns></returns> internal static Collection <String> SearchFiles(string pattern, Collection <String> searchPaths) { MUIFileSearcher searcher = new MUIFileSearcher(pattern, searchPaths); return(searcher.Result); }
/// <summary> /// Get the file in different search paths corresponding to current culture. /// /// The file name to search is the filename part of path parameter. (Normally path /// parameter should contain only the filename part. But it is possible for /// RunspaceConfiguration to directly specify a hard coded path for help file there). /// /// </summary> /// <param name="file">This is the path to the file. If it has a path, we need to search under that path first</param> /// <param name="searchPaths">Additional search paths</param> /// <returns></returns> internal static string LocateFile(string file, Collection<String> searchPaths) { MUIFileSearcher searcher = new MUIFileSearcher(file, searchPaths, SearchMode.First); if (searcher.Result == null || searcher.Result.Count == 0) return null; return searcher.Result[0]; }
/// <summary> /// Search for files in specified search paths. /// </summary> /// <param name="pattern"></param> /// <param name="searchPaths"></param> /// <returns></returns> internal static Collection<String> SearchFiles(string pattern, Collection<String> searchPaths) { MUIFileSearcher searcher = new MUIFileSearcher(pattern, searchPaths); return searcher.Result; }
/// <summary> /// Load help file provided. /// </summary> /// <remarks> /// This will load providerHelpInfo from help file into help cache. /// </remarks> /// <param name="providerInfo">providerInfo for which to locate help.</param> private void LoadHelpFile(ProviderInfo providerInfo) { if (providerInfo == null) { throw PSTraceSource.NewArgumentNullException("providerInfo"); } string helpFile = providerInfo.HelpFile; if (String.IsNullOrEmpty(helpFile) || _helpFiles.Contains(helpFile)) { return; } string helpFileToLoad = helpFile; // Get the mshsnapinfo object for this cmdlet. PSSnapInInfo mshSnapInInfo = providerInfo.PSSnapIn; // Search fallback // 1. If PSSnapInInfo exists, then always look in the application base // of the mshsnapin // Otherwise, // Look in the default search path and cmdlet assembly path Collection <String> searchPaths = new Collection <String>(); if (mshSnapInInfo != null) { Diagnostics.Assert(!string.IsNullOrEmpty(mshSnapInInfo.ApplicationBase), "Application Base is null or empty."); // not minishell case.. // we have to search only in the application base for a mshsnapin... // if you create an absolute path for helpfile, then MUIFileSearcher // will look only in that path. helpFileToLoad = Path.Combine(mshSnapInInfo.ApplicationBase, helpFile); } else if ((providerInfo.Module != null) && (!string.IsNullOrEmpty(providerInfo.Module.Path))) { helpFileToLoad = Path.Combine(providerInfo.Module.ModuleBase, helpFile); } else { searchPaths.Add(GetDefaultShellSearchPath()); searchPaths.Add(GetProviderAssemblyPath(providerInfo)); } string location = MUIFileSearcher.LocateFile(helpFileToLoad, searchPaths); if (String.IsNullOrEmpty(location)) { throw new FileNotFoundException(helpFile); } XmlDocument doc = InternalDeserializer.LoadUnsafeXmlDocument( new FileInfo(location), false, /* ignore whitespace, comments, etc. */ null); /* default maxCharactersInDocument */ // Add this file into _helpFiles hashtable to prevent it to be loaded again. _helpFiles[helpFile] = 0; XmlNode helpItemsNode = null; if (doc.HasChildNodes) { for (int i = 0; i < doc.ChildNodes.Count; i++) { XmlNode node = doc.ChildNodes[i]; if (node.NodeType == XmlNodeType.Element && String.Compare(node.Name, "helpItems", StringComparison.OrdinalIgnoreCase) == 0) { helpItemsNode = node; break; } } } if (helpItemsNode == null) { return; } using (this.HelpSystem.Trace(location)) { if (helpItemsNode.HasChildNodes) { for (int i = 0; i < helpItemsNode.ChildNodes.Count; i++) { XmlNode node = helpItemsNode.ChildNodes[i]; if (node.NodeType == XmlNodeType.Element && String.Compare(node.Name, "providerHelp", StringComparison.OrdinalIgnoreCase) == 0) { HelpInfo helpInfo = ProviderHelpInfo.Load(node); if (helpInfo != null) { this.HelpSystem.TraceErrors(helpInfo.Errors); // Add snapin qualified type name for this command.. // this will enable customizations of the help object. helpInfo.FullHelp.TypeNames.Insert(0, string.Format(CultureInfo.InvariantCulture, "ProviderHelpInfo#{0}#{1}", providerInfo.PSSnapInName, helpInfo.Name)); if (!string.IsNullOrEmpty(providerInfo.PSSnapInName)) { helpInfo.FullHelp.Properties.Add(new PSNoteProperty("PSSnapIn", providerInfo.PSSnapIn)); helpInfo.FullHelp.TypeNames.Insert(1, string.Format(CultureInfo.InvariantCulture, "ProviderHelpInfo#{0}", providerInfo.PSSnapInName)); } AddCache(providerInfo.PSSnapInName + "\\" + helpInfo.Name, helpInfo); } } } } } }
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; } } } } } }
internal static string LocateFile(string file, Collection <string> searchPaths) { MUIFileSearcher muiFileSearcher = new MUIFileSearcher(file, searchPaths, SearchMode.First); return(muiFileSearcher.Result == null || muiFileSearcher.Result.Count == 0 ? (string)null : muiFileSearcher.Result[0]); }
internal static Collection <string> SearchFiles(string pattern) => MUIFileSearcher.SearchFiles(pattern, new Collection <string>());