Esempio n. 1
0
        private MamlCommandHelpInfo GetFromCommandCacheByRemovingPrefix(string helpIdentifier, CommandInfo cmdInfo)
        {
            MamlCommandHelpInfo info  = null;
            MamlCommandHelpInfo info2 = this.GetFromCommandCache(helpIdentifier, ModuleCmdletBase.RemovePrefixFromCommandName(cmdInfo.Name, cmdInfo.Prefix), cmdInfo.HelpCategory) as MamlCommandHelpInfo;

            if (info2 != null)
            {
                info = info2.Copy();
                if (info.FullHelp.Properties["Name"] != null)
                {
                    info.FullHelp.Properties.Remove("Name");
                }
                info.FullHelp.Properties.Add(new PSNoteProperty("Name", cmdInfo.Name));
                if ((info.FullHelp.Properties["Details"] == null) || (info.FullHelp.Properties["Details"].Value == null))
                {
                    return(info);
                }
                PSObject obj2 = PSObject.AsPSObject(info.FullHelp.Properties["Details"].Value).Copy();
                if (obj2.Properties["Name"] != null)
                {
                    obj2.Properties.Remove("Name");
                }
                obj2.Properties.Add(new PSNoteProperty("Name", cmdInfo.Name));
                info.FullHelp.Properties["Details"].Value = obj2;
            }
            return(info);
        }
        /// <summary>
        /// Gets the HelpInfo object corresponding to the command.
        /// </summary>
        /// <param name="helpFileIdentifier">help file identifier (either name of PSSnapIn or simply full path to help file)</param>
        /// <param name="helpCategory">Help Category for search.</param>
        /// <returns>HelpInfo object.</returns>
        private HelpInfo GetFromResourceHelpCache(string helpFileIdentifier, HelpCategory helpCategory)
        {
            Debug.Assert(!string.IsNullOrEmpty(helpFileIdentifier), "helpFileIdentifier should not be null or empty.");

            HelpInfo result = GetCache(helpFileIdentifier);

            if (result != null)
            {
                MamlCommandHelpInfo original = (MamlCommandHelpInfo)result;
                result = original.Copy(helpCategory);
            }

            return(result);
        }