Team Ai
Datasetpublic

MegaBites-AI/Windows-powershell

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes372downloads
HelpProviderWithFullCache.cs101 linesDownload Raw Back to help
1// Copyright (c) Microsoft Corporation.2// Licensed under the MIT License.3 4using System.Collections.Generic;5 6namespace System.Management.Automation7{8    /// <summary>9    /// Class HelpProviderWithFullCache provides a pseudo implementation of HelpProvider10    /// at which results are fully cached in a hashtable after initial cache load.11    ///12    /// This class is different from HelpProviderWithCache class in the sense that13    /// help contents for this provider can be loaded once and be used for later14    /// search. So logically class derived from this class only need to provide15    /// a way to load and initialize help cache.16    /// </summary>17    internal abstract class HelpProviderWithFullCache : HelpProviderWithCache18    {19        /// <summary>20        /// Constructor for HelpProviderWithFullCache.21        /// </summary>22        internal HelpProviderWithFullCache(HelpSystem helpSystem) : base(helpSystem)23        {24        }25 26        /// <summary>27        /// Exact match help for a target. This function will be sealed right here28        /// since this is no need for children class to override this member.29        /// </summary>30        /// <param name="helpRequest">Help request object.</param>31        /// <returns>The HelpInfo found. Null if nothing is found.</returns>32        internal sealed override IEnumerable<HelpInfo> ExactMatchHelp(HelpRequest helpRequest)33        {34            if (!this.CacheFullyLoaded)35            {36                LoadCache();37            }38 39            this.CacheFullyLoaded = true;40 41            return base.ExactMatchHelp(helpRequest);42        }43 44        /// <summary>45        /// Do exact match help for a target. This member is sealed right here since46        /// children class don't need to override this member.47        /// </summary>48        /// <param name="helpRequest">Help request object.</param>49        internal sealed override void DoExactMatchHelp(HelpRequest helpRequest)50        {51        }52 53        /// <summary>54        /// Search help for a target. This function will be sealed right here55        /// since this is no need for children class to override this member.56        /// </summary>57        /// <param name="helpRequest">Help request object.</param>58        /// <param name="searchOnlyContent">59        /// If true, searches for pattern in the help content. Individual60        /// provider can decide which content to search in.61        ///62        /// If false, searches for pattern in the command names.63        /// </param>64        /// <returns>A collection of help info objects.</returns>65        internal sealed override IEnumerable<HelpInfo> SearchHelp(HelpRequest helpRequest, bool searchOnlyContent)66        {67            if (!this.CacheFullyLoaded)68            {69                LoadCache();70            }71 72            this.CacheFullyLoaded = true;73 74            return base.SearchHelp(helpRequest, searchOnlyContent);75        }76 77        /// <summary>78        /// Do search help. This function will be sealed right here79        /// since this is no need for children class to override this member.80        /// </summary>81        /// <param name="helpRequest">Help request object.</param>82        /// <returns>A collection of help info objects.</returns>83        internal sealed override IEnumerable<HelpInfo> DoSearchHelp(HelpRequest helpRequest)84        {85            return null;86        }87 88        /// <summary>89        /// Load cache for later searching for help.90        /// </summary>91        /// <remarks>92        /// This is the only member child class need to override for help search purpose.93        /// This function will be called only once (usually this happens at the first time when94        /// end user request some help in the target help category).95        /// </remarks>96        internal virtual void LoadCache()97        {98        }99    }100}101