Пример #1
0
        /// <summary>
        /// Create a copy of current help request object.
        /// </summary>
        /// <returns></returns>
        internal HelpRequest Clone()
        {
            HelpRequest helpRequest = new HelpRequest(this.Target, this.HelpCategory);

            helpRequest.Provider = this.Provider;
            helpRequest.MaxResults = this.MaxResults;
            helpRequest.Component = this.Component;
            helpRequest.Role = this.Role;
            helpRequest.Functionality = this.Functionality;
            helpRequest.ProviderContext = this.ProviderContext;
            helpRequest.CommandOrigin = CommandOrigin;

            return helpRequest;
        }
        public static string GetHelpUri(PSObject commandInfoPSObject)
        {
            if (commandInfoPSObject == null)
            {
                return(string.Empty);
            }

            CommandInfo cmdInfo = PSObject.Base(commandInfoPSObject) as CommandInfo;

            // GetHelpUri helper method is expected to be used only by System.Management.Automation.CommandInfo
            // objects from types.ps1xml
            if ((cmdInfo == null) || (string.IsNullOrEmpty(cmdInfo.Name)))
            {
                return(string.Empty);
            }

            // The type checking is needed to avoid a try..catch exception block as
            // the CommandInfo.CommandMetadata throws an InvalidOperationException
            // instead of returning null.
            if ((cmdInfo is CmdletInfo) || (cmdInfo is FunctionInfo) ||
                (cmdInfo is ExternalScriptInfo) || (cmdInfo is ScriptInfo))
            {
                if (!string.IsNullOrEmpty(cmdInfo.CommandMetadata.HelpUri))
                {
                    return(cmdInfo.CommandMetadata.HelpUri);
                }
            }

            AliasInfo aliasInfo = cmdInfo as AliasInfo;

            if ((aliasInfo != null) &&
                (aliasInfo.ExternalCommandMetadata != null) &&
                (!string.IsNullOrEmpty(aliasInfo.ExternalCommandMetadata.HelpUri)))
            {
                return(aliasInfo.ExternalCommandMetadata.HelpUri);
            }

            // if everything else fails..depend on Get-Help infrastructure to get us the Uri.
            string cmdName = cmdInfo.Name;

            if (!string.IsNullOrEmpty(cmdInfo.ModuleName))
            {
                cmdName = string.Format(CultureInfo.InvariantCulture,
                                        "{0}\\{1}", cmdInfo.ModuleName, cmdInfo.Name);
            }

            if (DoesCurrentRunspaceIncludeCoreHelpCmdlet())
            {
                // Win8: 651300 if core get-help is present in the runspace (and it is the only get-help command), use
                // help system directly and avoid perf penalty.
                var currentContext = System.Management.Automation.Runspaces.LocalPipeline.GetExecutionContextFromTLS();
                if ((currentContext != null) && (currentContext.HelpSystem != null))
                {
                    HelpRequest helpRequest = new HelpRequest(cmdName, cmdInfo.HelpCategory);
                    helpRequest.ProviderContext = new ProviderContext(
                        string.Empty,
                        currentContext,
                        currentContext.SessionState.Path);
                    helpRequest.CommandOrigin = CommandOrigin.Runspace;
                    foreach (
                        Uri result in
                        currentContext.HelpSystem.ExactMatchHelp(helpRequest).Select(
                            helpInfo => helpInfo.GetUriForOnlineHelp()).Where(static result => result != null))
Пример #3
0
 public void Remove(HelpRequest helpRequest)
 {
     manager.removeHelpRequest(helpRequest);
 }
Пример #4
0
 public async Task DeleteHelpRequest(HelpRequest helpRequest)
 {
     _unitOfWork.HelpRequests.Remove(helpRequest);
     await _unitOfWork.CommitAsync();
 }
Пример #5
0
 public async Task UpdateHelpRequest(HelpRequest helpRequestToBeUpdated, HelpRequest helpRequest)
 {
     helpRequestToBeUpdated = helpRequest;
     await _unitOfWork.CommitAsync();
 }
Пример #6
0
        /// <summary>
        /// Implements the ProcessRecord() method for get-help command
        /// </summary>
        protected override void ProcessRecord()
        {
            try
            {
#if !CORECLR
                if (this.ShowWindow)
                {
                    this.graphicalHostReflectionWrapper = GraphicalHostReflectionWrapper.GetGraphicalHostReflectionWrapper(this, "Microsoft.PowerShell.Commands.Internal.HelpWindowHelper");
                }
#endif
                this.Context.HelpSystem.OnProgress += new HelpSystem.HelpProgressHandler(HelpSystem_OnProgress);

                bool         failed       = false;
                HelpCategory helpCategory = ToHelpCategory(Category, ref failed);

                if (failed)
                {
                    return;
                }

                // Validate input parameters
                ValidateAndThrowIfError(helpCategory);

                HelpRequest helpRequest = new HelpRequest(this.Name, helpCategory);

                helpRequest.Provider        = _provider;
                helpRequest.Component       = Component;
                helpRequest.Role            = Role;
                helpRequest.Functionality   = Functionality;
                helpRequest.ProviderContext = new ProviderContext(
                    this.Path,
                    this.Context.Engine.Context,
                    this.SessionState.Path);
                helpRequest.CommandOrigin = this.MyInvocation.CommandOrigin;

                // the idea is to use yield statement in the help lookup to speed up
                // perceived user experience....So HelpSystem.GetHelp returns an
                // IEnumerable..
                IEnumerable <HelpInfo> helpInfos = this.Context.HelpSystem.GetHelp(helpRequest);
                // HelpCommand acts differently when there is just one help object and when
                // there are more than one object...so handling this behavior through
                // some variables.
                HelpInfo firstHelpInfoObject = null;
                int      countOfHelpInfos    = 0;
                foreach (HelpInfo helpInfo in helpInfos)
                {
                    // honor Ctrl-C from user.
                    if (IsStopping)
                    {
                        return;
                    }

                    if (0 == countOfHelpInfos)
                    {
                        firstHelpInfoObject = helpInfo;
                    }
                    else
                    {
                        // write first help object only once.
                        if (null != firstHelpInfoObject)
                        {
                            WriteObjectsOrShowOnlineHelp(firstHelpInfoObject, false);
                            firstHelpInfoObject = null;
                        }

                        WriteObjectsOrShowOnlineHelp(helpInfo, false);
                    }
                    countOfHelpInfos++;
                }

                _timer.Stop();

                if (!string.IsNullOrEmpty(Name))
                {
                    Microsoft.PowerShell.Telemetry.Internal.TelemetryAPI.ReportGetHelpTelemetry(Name, countOfHelpInfos, _timer.ElapsedMilliseconds, _updatedHelp);
                }

                // Write full help as there is only one help info object
                if (1 == countOfHelpInfos)
                {
                    WriteObjectsOrShowOnlineHelp(firstHelpInfoObject, true);
                }
                else if (_showOnlineHelp && (countOfHelpInfos > 1))
                {
                    throw PSTraceSource.NewInvalidOperationException(HelpErrors.MultipleOnlineTopicsNotSupported, "Online");
                }

                // show errors only if there is no wildcard search or VerboseHelpErrors is true.
                if (((countOfHelpInfos == 0) && (!WildcardPattern.ContainsWildcardCharacters(helpRequest.Target))) ||
                    this.Context.HelpSystem.VerboseHelpErrors)
                {
                    // Check if there is any error happened. If yes,
                    // pipe out errors.
                    if (this.Context.HelpSystem.LastErrors.Count > 0)
                    {
                        foreach (ErrorRecord errorRecord in this.Context.HelpSystem.LastErrors)
                        {
                            WriteError(errorRecord);
                        }
                    }
                }
            }
            finally
            {
                this.Context.HelpSystem.OnProgress -= new HelpSystem.HelpProgressHandler(HelpSystem_OnProgress);
                // finally clear the ScriptBlockAst -> Token[] cache
                this.Context.HelpSystem.ClearScriptBlockTokenCache();
            }
        }
Пример #7
0
 /// <summary>
 /// Search help info that match the target search pattern.
 /// </summary>
 /// <param name="helpRequest">Help request object.</param>
 /// <param name="searchOnlyContent">
 /// If true, searches for pattern in the help content. Individual
 /// provider can decide which content to search in.
 ///
 /// If false, searches for pattern in the command names.
 /// </param>
 /// <returns>A collection of help info objects.</returns>
 internal abstract IEnumerable <HelpInfo> SearchHelp(HelpRequest helpRequest, bool searchOnlyContent);
Пример #8
0
        /// <summary>
        /// See <a href="http://docs.amazonwebservices.com/AWSMechTurk/2012-03-25/AWSMturkAPI/ApiReference_HelpOperation.html">online documentation for this operation.</a>
        /// </summary>
        /// <param name="about">The topics to retrieve help for</param>
        /// <param name="type">A <see cref="Nullable&lt;HelpRequestHelpType&gt;"/> instance containing the request parameters</param>
        /// <returns>A <see cref="Information"/> instance</returns>
        public Information Help(List<string> about, HelpRequestHelpType? type)
        {
            if (about == null || about.Count == 0)
            {
                throw new ArgumentException("No help topics specified", "about");
            }

            HelpRequest request = new HelpRequest();
            request.About = about.ToArray();

            if (type.HasValue)
            {
                request.HelpType = type.Value;
                request.HelpTypeSpecified = true;
            }

            return Proxy.Help(request);
        }
Пример #9
0
        public void HelpRequestManagerFullTest()
        {
            LocalUser                 user                   = Login();
            var                       statusManager          = HelpRequestManager.ManagerStatus.UnknownError;
            var                       statusGetterHelp       = HelpRequestGetter.GetStatus.UnknownError;
            var                       statusGetterCategories = CategoriesGetter.GetStatus.UnknownError;
            bool                      done                   = false;
            HelpRequest               helpRequest;
            List <HelpRequest>        helpRequests = null;
            Dictionary <String, User> users        = null;
            List <Category>           categories   = null;

            var helpRequestManager = new HelpRequestManager(user);

            helpRequestManager.PostHelpRequestResult = (_status, _helpRequest) =>
            {
                statusManager = _status;
                helpRequest   = _helpRequest;
                done          = true;
            };

            helpRequestManager.RemoveHelpRequestResult = (_status, _helpRequest) =>
            {
                statusManager = _status;
                helpRequest   = _helpRequest;
                done          = true;
            };

            var getterHelp = new HelpRequestGetter(user, (_status, _helpRequests, _users) => {
                statusGetterHelp = _status;
                helpRequests     = _helpRequests;
                users            = _users;
                done             = true;
            });

            var getterCategories = new CategoriesGetter(user, (_status, _categories) => {
                statusGetterCategories = _status;
                categories             = _categories;
                done = true;
            });

            ///Gaunam Kategorijas
            done = false;
            getterCategories.get();
            while (!done)
            {
            }
            Assert.AreEqual(statusGetterCategories, CategoriesGetter.GetStatus.Success);
            Assert.AreNotEqual(categories, null);
            Assert.AreNotEqual(categories.Count, 0);
            ///

            ///Siunčiam helpRequest
            done = false;
            var random = new Random();

            helpRequest = new HelpRequest {
                Title = random.Next().ToString(), Description = random.Next().ToString(), Category = categories[0].Title
            };
            helpRequestManager.postHelpRequest(helpRequest);

            while (!done)
            {
            }
            Assert.AreEqual(statusManager, HelpRequestManager.ManagerStatus.Success);
            Assert.AreNotEqual(helpRequest, null);
            ///

            ///Gaunam visus helpRequest
            done = false;
            getterHelp.get(true);
            while (!done)
            {
            }

            Assert.AreEqual(statusGetterHelp, HelpRequestGetter.GetStatus.Success);
            Assert.AreNotEqual(users, null);
            Assert.AreNotEqual(helpRequests, null);
            ///Tikrinam ar mūsų yra
            var myHelpRequest = helpRequests.Find((_helpRequest) =>
            {
                return(_helpRequest.Title == helpRequest.Title &&
                       _helpRequest.Description == helpRequest.Description &&
                       _helpRequest.CreatorUsername == user.Username &&
                       _helpRequest.Category == categories[0].Title);
            });

            Assert.AreNotEqual(myHelpRequest, null);
            ///

            ///Trinam helpRequest
            done = false;
            helpRequestManager.removeHelpRequest(helpRequest);

            while (!done)
            {
            }
            Assert.AreEqual(statusManager, HelpRequestManager.ManagerStatus.Success);
            Assert.AreNotEqual(helpRequest, null);
            ///


            ///Gaunam visus helpRequest
            done = false;
            getterHelp.get(true);
            while (!done)
            {
            }

            Assert.AreEqual(statusGetterHelp, HelpRequestGetter.GetStatus.Success);
            Assert.AreNotEqual(users, null);
            Assert.AreNotEqual(helpRequests, null);
            ///Tikrinam ar mūsų nėra
            myHelpRequest = helpRequests.Find((_helpRequest) =>
            {
                return(_helpRequest.Title == helpRequest.Title &&
                       _helpRequest.Description == helpRequest.Description &&
                       _helpRequest.CreatorUsername == user.Username &&
                       _helpRequest.Category == categories[0].Title);
            });
            Assert.AreEqual(myHelpRequest, null);
            ///
        }
 /// <summary>
 /// Do search help. This function will be sealed right here
 /// since this is no need for children class to override this member.
 /// </summary>
 /// <param name="helpRequest">Help request object.</param>
 /// <returns>A collection of help info objects.</returns>
 internal sealed override IEnumerable <HelpInfo> DoSearchHelp(HelpRequest helpRequest)
 {
     return(null);
 }
Пример #11
0
 protected override void ProcessRecord()
 {
     try
     {
         if (this.ShowWindow != 0)
         {
             this.graphicalHostReflectionWrapper = GraphicalHostReflectionWrapper.GetGraphicalHostReflectionWrapper(this, "Microsoft.PowerShell.Commands.Internal.HelpWindowHelper");
         }
         base.Context.HelpSystem.OnProgress += new HelpSystem.HelpProgressHandler(this.HelpSystem_OnProgress);
         bool         failed = false;
         HelpCategory cat    = this.ToHelpCategory(this._category, ref failed);
         if (!failed)
         {
             this.ValidateAndThrowIfError(cat);
             HelpRequest helpRequest = new HelpRequest(this.Name, cat)
             {
                 Provider        = this._provider,
                 Component       = this._component,
                 Role            = this._role,
                 Functionality   = this._functionality,
                 ProviderContext = new ProviderContext(this.Path, base.Context.Engine.Context, base.SessionState.Path),
                 CommandOrigin   = base.MyInvocation.CommandOrigin
             };
             IEnumerable <HelpInfo> help = base.Context.HelpSystem.GetHelp(helpRequest);
             HelpInfo helpInfo           = null;
             int      num = 0;
             foreach (HelpInfo info2 in help)
             {
                 if (base.IsStopping)
                 {
                     return;
                 }
                 if (num == 0)
                 {
                     helpInfo = info2;
                 }
                 else
                 {
                     if (helpInfo != null)
                     {
                         this.WriteObjectsOrShowOnlineHelp(helpInfo, false);
                         helpInfo = null;
                     }
                     this.WriteObjectsOrShowOnlineHelp(info2, false);
                 }
                 num++;
             }
             if (1 == num)
             {
                 this.WriteObjectsOrShowOnlineHelp(helpInfo, true);
             }
             else if (this.showOnlineHelp && (num > 1))
             {
                 throw PSTraceSource.NewInvalidOperationException("HelpErrors", "MultipleOnlineTopicsNotSupported", new object[] { "Online" });
             }
             if ((((num == 0) && !WildcardPattern.ContainsWildcardCharacters(helpRequest.Target)) || base.Context.HelpSystem.VerboseHelpErrors) && (base.Context.HelpSystem.LastErrors.Count > 0))
             {
                 foreach (ErrorRecord record in base.Context.HelpSystem.LastErrors)
                 {
                     base.WriteError(record);
                 }
             }
         }
     }
     finally
     {
         base.Context.HelpSystem.OnProgress -= new HelpSystem.HelpProgressHandler(this.HelpSystem_OnProgress);
         base.Context.HelpSystem.ClearScriptBlockTokenCache();
     }
 }
 /// <summary>
 /// Do exact match help for a target. This member is sealed right here since
 /// children class don't need to override this member.
 /// </summary>
 /// <param name="helpRequest">Help request object.</param>
 internal sealed override void DoExactMatchHelp(HelpRequest helpRequest)
 {
 }
Пример #13
0
 public void Post(HelpRequest helpRequest)
 {
     manager.postHelpRequest(helpRequest);
 }
Пример #14
0
 /// <summary>
 /// Process a helpinfo forwarded over by another help provider.
 ///
 /// HelpProvider can choose to process the helpInfo or not,
 ///
 ///     1. If a HelpProvider chooses not to process the helpInfo, it can return null to indicate
 ///        helpInfo is not processed.
 ///     2. If a HelpProvider indeed processes the helpInfo, it should create a new helpInfo
 ///        object instead of modifying the passed-in helpInfo object. This is very important
 ///        since the helpInfo object passed in is usually stored in cache, which can
 ///        used in later queries.
 /// </summary>
 /// <param name="helpInfo">HelpInfo passed over by another HelpProvider.</param>
 /// <param name="helpRequest">Help request object.</param>
 /// <returns></returns>
 internal virtual IEnumerable <HelpInfo> ProcessForwardedHelp(HelpInfo helpInfo, HelpRequest helpRequest)
 {
     // Win8: 508648. Remove the current provides category for resolving forward help as the current
     // help provider already process it.
     helpInfo.ForwardHelpCategory ^= this.HelpCategory;
     yield return(helpInfo);
 }
Пример #15
0
 public static void InvokeHelpRequest(Mobile m) => HelpRequest?.Invoke(m);
Пример #16
0
        /// <summary>
        /// The Help operation returns information about the Mechanical Turk Service operations and 
        /// response groups. You can use it to facilitate development and documentation of your web 
        /// site and tools.
        /// </summary>
        /// <param name="request">A <see cref="HelpRequest"/> instance containing 
        /// the request parameters</param>
        /// <returns>A <see cref="Information"/> instance</returns>
        public Information Help(HelpRequest request)
        {
            HelpResponse response = (HelpResponse)(this.SendRequest(request));

            return response.Information[0];
        }
Пример #17
0
 public static string GetHelpUri(PSObject commandInfoPSObject)
 {
     if (commandInfoPSObject != null)
     {
         CommandInfo info = PSObject.Base(commandInfoPSObject) as CommandInfo;
         if ((info == null) || string.IsNullOrEmpty(info.Name))
         {
             return(string.Empty);
         }
         if ((((info is CmdletInfo) || (info is FunctionInfo)) || ((info is ExternalScriptInfo) || (info is ScriptInfo))) && !string.IsNullOrEmpty(info.CommandMetadata.HelpUri))
         {
             return(info.CommandMetadata.HelpUri);
         }
         AliasInfo info2 = info as AliasInfo;
         if (((info2 != null) && (info2._externalCommandMetadata != null)) && !string.IsNullOrEmpty(info2._externalCommandMetadata.HelpUri))
         {
             return(info2._externalCommandMetadata.HelpUri);
         }
         string name = info.Name;
         if (!string.IsNullOrEmpty(info.ModuleName))
         {
             name = string.Format(CultureInfo.InvariantCulture, @"{0}\{1}", new object[] { info.ModuleName, info.Name });
         }
         if (DoesCurrentRunspaceIncludeCoreHelpCmdlet())
         {
             ExecutionContext executionContextFromTLS = LocalPipeline.GetExecutionContextFromTLS();
             if ((executionContextFromTLS != null) && (executionContextFromTLS.HelpSystem != null))
             {
                 HelpRequest helpRequest = new HelpRequest(name, info.HelpCategory)
                 {
                     ProviderContext = new ProviderContext(string.Empty, executionContextFromTLS, executionContextFromTLS.SessionState.Path),
                     CommandOrigin   = CommandOrigin.Runspace
                 };
                 foreach (Uri uri in from helpInfo in executionContextFromTLS.HelpSystem.ExactMatchHelp(helpRequest)
                          select helpInfo.GetUriForOnlineHelp() into result
                          where null != result
                          select result)
                 {
                     return(uri.OriginalString);
                 }
             }
         }
         else
         {
             using (PowerShell shell = PowerShell.Create(RunspaceMode.CurrentRunspace).AddCommand("get-help").AddParameter("Name", name).AddParameter("Category", info.HelpCategory.ToString()))
             {
                 Collection <PSObject> collection = shell.Invoke();
                 if (collection != null)
                 {
                     for (int i = 0; i < collection.Count; i++)
                     {
                         HelpInfo info3;
                         if (LanguagePrimitives.TryConvertTo <HelpInfo>(collection[i], out info3))
                         {
                             Uri uriForOnlineHelp = info3.GetUriForOnlineHelp();
                             if (null != uriForOnlineHelp)
                             {
                                 return(uriForOnlineHelp.OriginalString);
                             }
                         }
                         else
                         {
                             Uri uriFromCommandPSObject = BaseCommandHelpInfo.GetUriFromCommandPSObject(collection[i]);
                             return((uriFromCommandPSObject != null) ? uriFromCommandPSObject.OriginalString : string.Empty);
                         }
                     }
                 }
             }
         }
     }
     return(string.Empty);
 }
Пример #18
0
 void OnDialogHelpRequest(object sender, EventArgs e)
 {
     HelpRequest.Do(x => x(sender, e));
     HelpRequestCommand.If(x => x.CanExecute(e)).Do(x => x.Execute(e));
 }
Пример #19
0
        public static string GetHelpUri(PSObject commandInfoPSObject)
        {
            if (null == commandInfoPSObject)
            {
                return(string.Empty);
            }
            CommandInfo cmdInfo = PSObject.Base(commandInfoPSObject) as CommandInfo;

            // GetHelpUri helper method is expected to be used only by System.Management.Automation.CommandInfo
            // objects from types.ps1xml
            if ((null == cmdInfo) || (string.IsNullOrEmpty(cmdInfo.Name)))
            {
                return(string.Empty);
            }

            // The type checking is needed to avoid a try..catch exception block as
            // the CommandInfo.CommandMetadata throws an InvalidOperationException
            // instead of returning null.
            if ((cmdInfo is CmdletInfo) || (cmdInfo is FunctionInfo) ||
                (cmdInfo is ExternalScriptInfo) || (cmdInfo is ScriptInfo))
            {
                if (!string.IsNullOrEmpty(cmdInfo.CommandMetadata.HelpUri))
                {
                    return(cmdInfo.CommandMetadata.HelpUri);
                }
            }

            AliasInfo aliasInfo = cmdInfo as AliasInfo;

            if ((null != aliasInfo) &&
                (null != aliasInfo.ExternalCommandMetadata) &&
                (!string.IsNullOrEmpty(aliasInfo.ExternalCommandMetadata.HelpUri)))
            {
                return(aliasInfo.ExternalCommandMetadata.HelpUri);
            }

            // if everything else fails..depend on Get-Help infrastructure to get us the Uri.
            string cmdName = cmdInfo.Name;

            if (!string.IsNullOrEmpty(cmdInfo.ModuleName))
            {
                cmdName = string.Format(CultureInfo.InvariantCulture,
                                        "{0}\\{1}", cmdInfo.ModuleName, cmdInfo.Name);
            }

            if (DoesCurrentRunspaceIncludeCoreHelpCmdlet())
            {
                // Win8: 651300 if core get-help is present in the runspace (and it is the only get-help command), use
                // help system directly and avoid perf penalty.
                var currentContext = System.Management.Automation.Runspaces.LocalPipeline.GetExecutionContextFromTLS();
                if ((null != currentContext) && (null != currentContext.HelpSystem))
                {
                    HelpRequest helpRequest = new HelpRequest(cmdName, cmdInfo.HelpCategory);
                    helpRequest.ProviderContext = new ProviderContext(
                        string.Empty,
                        currentContext,
                        currentContext.SessionState.Path);
                    helpRequest.CommandOrigin = CommandOrigin.Runspace;
                    foreach (
                        Uri result in
                        currentContext.HelpSystem.ExactMatchHelp(helpRequest).Select(
                            helpInfo => helpInfo.GetUriForOnlineHelp()).Where(result => null != result))
                    {
                        return(result.OriginalString);
                    }
                }
            }
            else
            {
                // win8: 546025. Using Get-Help as command, instead of calling HelpSystem.ExactMatchHelp
                // for the following reasons:
                // 1. Exchange creates proxies for Get-Command and Get-Help in their scenario
                // 2. This method is primarily used to get uri faster while serializing the CommandInfo objects (from Get-Command)
                // 3. Exchange uses Get-Help proxy to not call Get-Help cmdlet at-all while serializing CommandInfo objects
                // 4. Using HelpSystem directly will not allow Get-Help proxy to do its job.
                System.Management.Automation.PowerShell getHelpPS = System.Management.Automation.PowerShell.Create(
                    RunspaceMode.CurrentRunspace).AddCommand("get-help").
                                                                    AddParameter("Name", cmdName).AddParameter("Category",
                                                                                                               cmdInfo.HelpCategory.ToString());
                try
                {
                    Collection <PSObject> helpInfos = getHelpPS.Invoke();

                    if (null != helpInfos)
                    {
                        for (int index = 0; index < helpInfos.Count; index++)
                        {
                            HelpInfo helpInfo;
                            if (LanguagePrimitives.TryConvertTo <HelpInfo>(helpInfos[index], out helpInfo))
                            {
                                Uri result = helpInfo.GetUriForOnlineHelp();
                                if (null != result)
                                {
                                    return(result.OriginalString);
                                }
                            }
                            else
                            {
                                Uri result = BaseCommandHelpInfo.GetUriFromCommandPSObject(helpInfos[index]);
                                return((result != null) ? result.OriginalString : string.Empty);
                            }
                        }
                    }
                }
                finally
                {
                    getHelpPS.Dispose();
                }
            }

            return(string.Empty);
        }
Пример #20
0
 /// <summary>
 /// Retrieve help info that exactly match the target.
 /// </summary>
 /// <param name="helpRequest">Help request object.</param>
 /// <returns>List of HelpInfo objects retrieved.</returns>
 internal abstract IEnumerable <HelpInfo> ExactMatchHelp(HelpRequest helpRequest);