Exemplo n.º 1
0
 private void HelpSystem_OnProgress(object sender, HelpProgressInfo arg)
 {
     ProgressRecord progressRecord = new ProgressRecord(0, base.CommandInfo.Name, arg.Activity) {
         PercentComplete = arg.PercentComplete
     };
     base.WriteProgress(progressRecord);
 }
Exemplo n.º 2
0
        private IEnumerable <HelpInfo> SearchHelp(HelpRequest helpRequest)
        {
            int              iteratorVariable0 = 0;
            bool             searchOnlyContent = false;
            bool             iteratorVariable2 = false;
            HelpProgressInfo arg = new HelpProgressInfo {
                Activity        = StringUtil.Format(HelpDisplayStrings.SearchingForHelpContent, helpRequest.Target),
                Completed       = false,
                PercentComplete = 0
            };

            this.OnProgress(this, arg);
            do
            {
                if (searchOnlyContent)
                {
                    iteratorVariable2 = true;
                }
                for (int i = 0; i < this.HelpProviders.Count; i++)
                {
                    HelpProvider iteratorVariable5 = (HelpProvider)this.HelpProviders[i];
                    if ((iteratorVariable5.HelpCategory & helpRequest.HelpCategory) > HelpCategory.None)
                    {
                        foreach (HelpInfo iteratorVariable6 in iteratorVariable5.SearchHelp(helpRequest, searchOnlyContent))
                        {
                            if (this._executionContext.CurrentPipelineStopping)
                            {
                                break;
                            }
                            iteratorVariable0++;
                            yield return(iteratorVariable6);

                            if ((iteratorVariable0 >= helpRequest.MaxResults) && (helpRequest.MaxResults > 0))
                            {
                                break;
                            }
                        }
                    }
                }
                if (iteratorVariable0 > 0)
                {
                    break;
                }
                searchOnlyContent = true;
                if (this.HelpProviders.Count > 0)
                {
                    arg.PercentComplete += 100 / this.HelpProviders.Count;
                    this.OnProgress(this, arg);
                }
            }while (!iteratorVariable2);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Get help that exactly match the target
        /// </summary>
        /// <param name="helpRequest">help request object</param>
        /// <returns>An IEnumerable of HelpInfo object</returns>
        private IEnumerable <HelpInfo> SearchHelp(HelpRequest helpRequest)
        {
            int  countOfHelpInfosFound = 0;
            bool searchInHelpContent   = false;
            bool shouldBreak           = false;

            HelpProgressInfo progress = new HelpProgressInfo();

            progress.Activity        = StringUtil.Format(HelpDisplayStrings.SearchingForHelpContent, helpRequest.Target);
            progress.Completed       = false;
            progress.PercentComplete = 0;

            try
            {
                OnProgress(this, progress);

                // algorithm:
                // 1. Search for pattern (helpRequest.Target) in command name
                // 2. If Step 1 fails then search for pattern in help content
                do
                {
                    // we should not continue the search loop if we are
                    // searching in the help content (as this is the last step
                    // in our search algorithm).
                    if (searchInHelpContent)
                    {
                        shouldBreak = true;
                    }

                    for (int i = 0; i < this.HelpProviders.Count; i++)
                    {
                        HelpProvider helpProvider = (HelpProvider)this.HelpProviders[i];
                        if ((helpProvider.HelpCategory & helpRequest.HelpCategory) > 0)
                        {
                            foreach (HelpInfo helpInfo in helpProvider.SearchHelp(helpRequest, searchInHelpContent))
                            {
                                if (_executionContext.CurrentPipelineStopping)
                                {
                                    yield break;
                                }

                                countOfHelpInfosFound++;
                                yield return(helpInfo);

                                if ((countOfHelpInfosFound >= helpRequest.MaxResults) && (helpRequest.MaxResults > 0))
                                {
                                    yield break;
                                }
                            }
                        }
                    }

                    // no need to do help content search once we have some help topics
                    // with command name search.
                    if (countOfHelpInfosFound > 0)
                    {
                        yield break;
                    }

                    // appears that we did not find any help matching command names..look for
                    // pattern in help content.
                    searchInHelpContent = true;

                    if (this.HelpProviders.Count > 0)
                    {
                        progress.PercentComplete += (100 / this.HelpProviders.Count);
                        OnProgress(this, progress);
                    }
                } while (!shouldBreak);
            }
            finally
            {
                progress.Completed       = true;
                progress.PercentComplete = 100;

                OnProgress(this, progress);
            }
        }
Exemplo n.º 4
0
 private IEnumerable<HelpInfo> SearchHelp(HelpRequest helpRequest)
 {
     int iteratorVariable0 = 0;
     bool searchOnlyContent = false;
     bool iteratorVariable2 = false;
     HelpProgressInfo arg = new HelpProgressInfo {
         Activity = StringUtil.Format(HelpDisplayStrings.SearchingForHelpContent, helpRequest.Target),
         Completed = false,
         PercentComplete = 0
     };
     this.OnProgress(this, arg);
     do
     {
         if (searchOnlyContent)
         {
             iteratorVariable2 = true;
         }
         for (int i = 0; i < this.HelpProviders.Count; i++)
         {
             HelpProvider iteratorVariable5 = (HelpProvider) this.HelpProviders[i];
             if ((iteratorVariable5.HelpCategory & helpRequest.HelpCategory) > HelpCategory.None)
             {
                 foreach (HelpInfo iteratorVariable6 in iteratorVariable5.SearchHelp(helpRequest, searchOnlyContent))
                 {
                     if (this._executionContext.CurrentPipelineStopping)
                     {
                         break;
                     }
                     iteratorVariable0++;
                     yield return iteratorVariable6;
                     if ((iteratorVariable0 >= helpRequest.MaxResults) && (helpRequest.MaxResults > 0))
                     {
                         break;
                     }
                 }
             }
         }
         if (iteratorVariable0 > 0)
         {
             break;
         }
         searchOnlyContent = true;
         if (this.HelpProviders.Count > 0)
         {
             arg.PercentComplete += 100 / this.HelpProviders.Count;
             this.OnProgress(this, arg);
         }
     }
     while (!iteratorVariable2);
 }
Exemplo n.º 5
0
        /// <summary>
        /// Get help that exactly match the target
        /// </summary>
        /// <param name="helpRequest">help request object</param>
        /// <returns>An IEnumerable of HelpInfo object</returns>
        private IEnumerable<HelpInfo> SearchHelp(HelpRequest helpRequest)
        {
            int countOfHelpInfosFound = 0;
            bool searchInHelpContent = false;
            bool shouldBreak = false;

            HelpProgressInfo progress = new HelpProgressInfo();

            progress.Activity = StringUtil.Format(HelpDisplayStrings.SearchingForHelpContent, helpRequest.Target);
            progress.Completed = false;
            progress.PercentComplete = 0;

            try
            {
                OnProgress(this, progress);

                // algorithm:
                // 1. Search for pattern (helpRequest.Target) in command name
                // 2. If Step 1 fails then search for pattern in help content
                do
                {
                    // we should not continue the search loop if we are 
                    // searching in the help content (as this is the last step 
                    // in our search algorithm).
                    if (searchInHelpContent)
                    {
                        shouldBreak = true;
                    }

                    for (int i = 0; i < this.HelpProviders.Count; i++)
                    {
                        HelpProvider helpProvider = (HelpProvider)this.HelpProviders[i];
                        if ((helpProvider.HelpCategory & helpRequest.HelpCategory) > 0)
                        {
                            foreach (HelpInfo helpInfo in helpProvider.SearchHelp(helpRequest, searchInHelpContent))
                            {
                                if (_executionContext.CurrentPipelineStopping)
                                {
                                    yield break;
                                }

                                countOfHelpInfosFound++;
                                yield return helpInfo;

                                if ((countOfHelpInfosFound >= helpRequest.MaxResults) && (helpRequest.MaxResults > 0))
                                {
                                    yield break;
                                }
                            }
                        }
                    }

                    // no need to do help content search once we have some help topics
                    // with command name search.
                    if (countOfHelpInfosFound > 0)
                    {
                        yield break;
                    }

                    // appears that we did not find any help matching command names..look for
                    // pattern in help content.
                    searchInHelpContent = true;

                    if (this.HelpProviders.Count > 0)
                    {
                        progress.PercentComplete += (100 / this.HelpProviders.Count);
                        OnProgress(this, progress);
                    }
                } while (!shouldBreak);
            }
            finally
            {
                progress.Completed = true;
                progress.PercentComplete = 100;

                OnProgress(this, progress);
            }
        }
Exemplo n.º 6
0
        private void HelpSystem_OnProgress(object sender, HelpProgressInfo arg)
        {
            ProgressRecord record = new ProgressRecord(0, this.CommandInfo.Name, arg.Activity);

            record.PercentComplete = arg.PercentComplete;

            WriteProgress(record);
        }