Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        /// <summary>
        /// Get the help in for the PS Class Info.        ///
        /// </summary>
        /// <param name="searcher">Searcher for PS Classes.</param>
        /// <returns>Next HelpInfo object.</returns>
        private IEnumerable <HelpInfo> GetHelpInfo(PSClassSearcher searcher)
        {
            while (searcher.MoveNext())
            {
                PSClassInfo current = ((IEnumerator <PSClassInfo>)searcher).Current;

                string moduleName = current.Module.Name;
                string moduleDir  = current.Module.ModuleBase;

                if (!string.IsNullOrEmpty(moduleName) && !string.IsNullOrEmpty(moduleDir))
                {
                    string helpFileToFind = moduleName + "-Help.xml";

                    string helpFileName = null;

                    Collection <string> searchPaths = new Collection <string>();
                    searchPaths.Add(moduleDir);

                    string externalHelpFile = current.HelpFile;

                    if (!string.IsNullOrEmpty(externalHelpFile))
                    {
                        FileInfo      helpFileInfo = new FileInfo(externalHelpFile);
                        DirectoryInfo dirToSearch  = helpFileInfo.Directory;

                        if (dirToSearch.Exists)
                        {
                            searchPaths.Add(dirToSearch.FullName);
                            helpFileToFind = helpFileInfo.Name; // If external help file is specified. Then use it.
                        }
                    }

                    HelpInfo helpInfo = GetHelpInfoFromHelpFile(current, helpFileToFind, searchPaths, true, out helpFileName);

                    if (helpInfo != null)
                    {
                        yield return(helpInfo);
                    }
                }
            }
        }
Esempio n. 3
0
        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 GetFromPSClasseHelpCache(helpFile, Automation.HelpCategory.Class);
            }

            return null;
        }