private HelpInfo GetHelpInfoFromHelpFile(DscResourceInfo resourceInfo, string helpFileToFind, Collection <string> searchPaths, bool reportErrors, out string helpFile)
        {
            Dbg.Assert(resourceInfo != null, "Caller should verify that resourceInfo != 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, resourceInfo.Name, reportErrors);
                }

                return(GetFromResourceHelpCache(helpFile, Automation.HelpCategory.DscResource));
            }

            return(null);
        }
        /// <summary>
        /// Get the help in for the DscResource Info.        ///
        /// </summary>
        /// <param name="searcher">Searcher for DscResources.</param>
        /// <returns>Next HelpInfo object.</returns>
        private IEnumerable <HelpInfo> GetHelpInfo(DscResourceSearcher searcher)
        {
            while (searcher.MoveNext())
            {
                DscResourceInfo current = ((IEnumerator <DscResourceInfo>)searcher).Current;

                string moduleName = null;
                string moduleDir  = current.ParentPath;

                // for binary modules, current.Module is empty.
                // in such cases use the leaf folder of ParentPath as filename.
                if (current.Module != null)
                {
                    moduleName = current.Module.Name;
                }
                else if (!String.IsNullOrEmpty(moduleDir))
                {
                    string[] splitPath = moduleDir.Split(Utils.Separators.Backslash);
                    moduleName = splitPath[splitPath.Length - 1];
                }

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

                    string helpFileName = null;

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

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

                    if (helpInfo != null)
                    {
                        yield return(helpInfo);
                    }
                }
            }
        }
예제 #3
0
        private HelpInfo GetHelpInfoFromHelpFile(DscResourceInfo resourceInfo, string helpFileToFind, Collection<string> searchPaths, bool reportErrors, out string helpFile)
        {
            Dbg.Assert(resourceInfo != null, "Caller should verify that resourceInfo != 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, resourceInfo.Name, reportErrors);
                }

                return GetFromResourceHelpCache(helpFile, Automation.HelpCategory.DscResource);
            }

            return null;
        }