internal bool IsMatch(WildcardPattern namePattern, PSSnapinQualifiedName psSnapinQualifiedName) { bool result = false; if (psSnapinQualifiedName == null) { result = true; } else { if (namePattern == null) { if (string.Equals(Name, psSnapinQualifiedName.ShortName, StringComparison.OrdinalIgnoreCase) && IsPSSnapinNameMatch(psSnapinQualifiedName)) { result = true; } } else if (namePattern.IsMatch(Name) && IsPSSnapinNameMatch(psSnapinQualifiedName)) { result = true; } } return result; }
internal static List <CompletionResult> PSv2GenerateMatchSetOfCmdlets(CompletionExecutionHelper helper, string lastWord, string quote, bool completingAtStartOfLine) { bool flag; List <CompletionResult> results = new List <CompletionResult>(); if (PSv2IsCommandLikeCmdlet(lastWord, out flag)) { Exception exception; helper.CurrentPowerShell.AddCommand("Get-Command").AddParameter("Name", lastWord + "*").AddCommand("Sort-Object").AddParameter("Property", "Name"); Collection <PSObject> collection = helper.ExecuteCurrentPowerShell(out exception, null); if ((collection == null) || (collection.Count <= 0)) { return(results); } CommandAndName[] cmdlets = new CommandAndName[collection.Count]; for (int i = 0; i < collection.Count; i++) { PSObject psObject = collection[i]; string fullName = CmdletInfo.GetFullName(psObject); cmdlets[i] = new CommandAndName(psObject, PSSnapinQualifiedName.GetInstance(fullName)); } if (flag) { foreach (CommandAndName name in cmdlets) { AddCommandResult(name, true, completingAtStartOfLine, quote, results); } return(results); } PrependSnapInNameForSameCmdletNames(cmdlets, completingAtStartOfLine, quote, results); } return(results); }
/// <summary> /// Determines if the passed in name is either the fully-qualified pssnapin name or /// short name of the provider. /// </summary> /// <param name="providerName"> /// The name to compare with the provider name. /// </param> /// <returns> /// True if the name is the fully-qualified pssnapin name or the short name of the provider. /// </returns> internal bool NameEquals(string providerName) { PSSnapinQualifiedName qualifiedProviderName = PSSnapinQualifiedName.GetInstance(providerName); bool result = false; if (qualifiedProviderName != null) { // If the pssnapin name and provider name are specified, then both must match do // false loop { if (!string.IsNullOrEmpty(qualifiedProviderName.PSSnapInName)) { // After converting core snapins to load as modules, the providers will have Module property populated if (!string.Equals(qualifiedProviderName.PSSnapInName, this.PSSnapInName, StringComparison.OrdinalIgnoreCase) && !string.Equals(qualifiedProviderName.PSSnapInName, this.ModuleName, StringComparison.OrdinalIgnoreCase)) { break; } } result = string.Equals(qualifiedProviderName.ShortName, this.Name, StringComparison.OrdinalIgnoreCase); } while (false); } else { // If only the provider name is specified, then only the name must match result = string.Equals(providerName, Name, StringComparison.OrdinalIgnoreCase); } return result; }
private string[] GenerateMatchSetOfCmdlets( string lastWord, bool isPSSnapInSpecified, CultureInfo ci) { using (CommandCompletionBase.tracer.TraceMethod(lastWord, new object[0])) { string[] strArray = (string[])null; Collection <PSObject> collection = this.exec.ExecuteCommand(string.Format((IFormatProvider)CultureInfo.InvariantCulture, "& {{ trap {{ continue }} ; get-command '{0}' -type Cmdlet }}", (object)(lastWord + "*"))); if (collection != null && collection.Count > 0) { PSSnapinQualifiedName[] snapinQualifiedNameArray = new PSSnapinQualifiedName[collection.Count]; for (int index = 0; index < collection.Count; ++index) { string fullName = CmdletInfo.GetFullName(collection[index]); snapinQualifiedNameArray[index] = PSSnapinQualifiedName.GetInstance(fullName); } Array.Sort <PSSnapinQualifiedName>(snapinQualifiedNameArray, new Comparison <PSSnapinQualifiedName>(CommandCompletionBase.PSSnapinQualifiedNameComparison)); if (isPSSnapInSpecified) { strArray = new string[collection.Count]; for (int index = 0; index < snapinQualifiedNameArray.Length; ++index) { strArray[index] = snapinQualifiedNameArray[index].FullName; } } else { strArray = CommandCompletionBase.PrependPSSnapInNameForSameCmdletNames(snapinQualifiedNameArray); } } return(strArray); } }
private static int PSSnapinQualifiedNameComparison( PSSnapinQualifiedName first, PSSnapinQualifiedName second) { int num = string.Compare(first.ShortName, second.ShortName, StringComparison.OrdinalIgnoreCase); return(num == 0 ? string.Compare(first.PSSnapInName, second.PSSnapInName, StringComparison.OrdinalIgnoreCase) : num); }
private bool IsPSSnapinNameMatch(PSSnapinQualifiedName psSnapinQualifiedName) { bool flag = false; if (!string.IsNullOrEmpty(psSnapinQualifiedName.PSSnapInName) && !string.Equals(psSnapinQualifiedName.PSSnapInName, this.PSSnapInName, StringComparison.OrdinalIgnoreCase)) { return(flag); } return(true); }
private CommandInfo GetFunction(string function) { CommandInfo commandInfo = (CommandInfo)this._context.EngineSessionState.GetFunction(function); if (commandInfo != null) { if (commandInfo is FilterInfo) { CommandDiscovery.discoveryTracer.WriteLine("Filter found: {0}", (object)function); } else { CommandDiscovery.discoveryTracer.WriteLine("Function found: {0} {1}", (object)function); } } else if (function.IndexOf('\\') > 0) { PSSnapinQualifiedName instance = PSSnapinQualifiedName.GetInstance(function); if (instance != null && !string.IsNullOrEmpty(instance.PSSnapInName)) { string psSnapInName = instance.PSSnapInName; PSModuleInfo psModuleInfo1 = (PSModuleInfo)null; List <PSModuleInfo> modules = this._context.Modules.GetModules(new string[1] { psSnapInName }, false); if (modules != null) { if (modules.Count == 1) { if (modules[0].ModuleType != ModuleType.Binary) { psModuleInfo1 = modules[0]; } } else { foreach (PSModuleInfo psModuleInfo2 in modules) { if (psModuleInfo2.ModuleType != ModuleType.Binary) { psModuleInfo1 = psModuleInfo2; break; } } } if (psModuleInfo1 != null && psModuleInfo1.ExportedFunctions.ContainsKey(instance.ShortName)) { commandInfo = (CommandInfo)psModuleInfo1.ExportedFunctions[instance.ShortName]; } } } } return(commandInfo); }
internal bool IsMatch(string providerName) { PSSnapinQualifiedName instance = PSSnapinQualifiedName.GetInstance(providerName); WildcardPattern namePattern = null; if ((instance != null) && WildcardPattern.ContainsWildcardCharacters(instance.ShortName)) { namePattern = new WildcardPattern(instance.ShortName, WildcardOptions.IgnoreCase); } return(this.IsMatch(namePattern, instance)); }
private bool IsPSSnapinNameMatch(PSSnapinQualifiedName psSnapinQualifiedName) { bool result = false; if (string.IsNullOrEmpty(psSnapinQualifiedName.PSSnapInName) || string.Equals(psSnapinQualifiedName.PSSnapInName, PSSnapInName, StringComparison.OrdinalIgnoreCase)) { result = true; } return result; }
internal bool IsMatch(string providerName) { PSSnapinQualifiedName psSnapinQualifiedName = PSSnapinQualifiedName.GetInstance(providerName); WildcardPattern namePattern = null; if (psSnapinQualifiedName != null && WildcardPattern.ContainsWildcardCharacters(psSnapinQualifiedName.ShortName)) { namePattern = WildcardPattern.Get(psSnapinQualifiedName.ShortName, WildcardOptions.IgnoreCase); } return IsMatch(namePattern, psSnapinQualifiedName); }
internal bool NameEquals(string providerName) { PSSnapinQualifiedName instance = PSSnapinQualifiedName.GetInstance(providerName); bool flag = false; if (instance != null) { if ((!string.IsNullOrEmpty(instance.PSSnapInName) && !string.Equals(instance.PSSnapInName, this.PSSnapInName, StringComparison.OrdinalIgnoreCase)) && !string.Equals(instance.PSSnapInName, this.ModuleName, StringComparison.OrdinalIgnoreCase)) { return(flag); } return(string.Equals(instance.ShortName, this.Name, StringComparison.OrdinalIgnoreCase)); } return(string.Equals(providerName, this.Name, StringComparison.OrdinalIgnoreCase)); }
internal static PSSnapinQualifiedName GetInstance(string name) { if (name == null) { return((PSSnapinQualifiedName)null); } string[] splitName = name.Split('\\'); if (splitName.Length < 0 || splitName.Length > 2) { return((PSSnapinQualifiedName)null); } PSSnapinQualifiedName snapinQualifiedName = new PSSnapinQualifiedName(splitName); return(string.IsNullOrEmpty(snapinQualifiedName.ShortName) ? (PSSnapinQualifiedName)null : snapinQualifiedName); }
/// <summary> /// Gets an instance of the Name class. /// </summary> /// /// <param name="name"> /// The name of the command. /// </param> /// /// <returns> /// An instance of the Name class. /// </returns> /// internal static PSSnapinQualifiedName GetInstance(string name) { if (name == null) return null; PSSnapinQualifiedName result = null; string[] splitName = name.Split(Utils.Separators.Backslash); if (splitName.Length < 0 || splitName.Length > 2) return null; result = new PSSnapinQualifiedName(splitName); // If the shortname is empty, then return null... if (String.IsNullOrEmpty(result.ShortName)) { return null; } return result; }
/// <summary> /// Gets an instance of the Name class. /// </summary> /// /// <param name="name"> /// The name of the command. /// </param> /// /// <returns> /// An instance of the Name class. /// </returns> /// internal static PSSnapinQualifiedName GetInstance(string name) { if (name == null) return null; PSSnapinQualifiedName result = null; string[] splitName = name.Split(Utils.Separators.Backslash); if (splitName.Length < 0 || splitName.Length > 2) return null; result = new PSSnapinQualifiedName(splitName); // If the shortname is empty, then return null... if (String.IsNullOrEmpty(result.ShortName)) { return null; } return result; }
private CommandInfo GetFunctionFromModules(string command) { FunctionInfo info = null; if (command.IndexOf('\\') > 0) { PSSnapinQualifiedName instance = PSSnapinQualifiedName.GetInstance(command); if ((instance != null) && !string.IsNullOrEmpty(instance.PSSnapInName)) { PSModuleInfo importedModuleByName = this.GetImportedModuleByName(instance.PSSnapInName); if (importedModuleByName != null) { importedModuleByName.ExportedFunctions.TryGetValue(instance.ShortName, out info); } } } return(info); }
internal Collection <CmdletInfo> GetCmdletInfo( PSSnapinQualifiedName commandName) { Collection <CmdletInfo> collection = new Collection <CmdletInfo>(); Dictionary <string, List <CmdletInfo> > cmdletCache = this._context.EngineSessionState.CmdletCache; while (true) { lock (cmdletCache) { if (cmdletCache.ContainsKey(commandName.ShortName)) { List <CmdletInfo> cmdletInfoList = cmdletCache[commandName.ShortName]; if (!string.IsNullOrEmpty(commandName.PSSnapInName)) { foreach (CmdletInfo cmdletInfo in cmdletInfoList) { if (string.Equals(cmdletInfo.ModuleName, commandName.PSSnapInName, StringComparison.OrdinalIgnoreCase)) { collection.Add(cmdletInfo); } } } else { foreach (CmdletInfo cmdletInfo in cmdletInfoList) { collection.Add(cmdletInfo); } } } } if (cmdletCache != this._context.TopLevelSessionState.CmdletCache) { cmdletCache = this._context.TopLevelSessionState.CmdletCache; } else { break; } } return(collection); }
private CmdletInfo GetNextCmdlet() { CmdletInfo result = null; if (this.matchingCmdlet == null) { if ((this.commandResolutionOptions & SearchResolutionOptions.CommandNameIsPattern) != SearchResolutionOptions.None) { Collection <CmdletInfo> collection = new Collection <CmdletInfo>(); PSSnapinQualifiedName instance = PSSnapinQualifiedName.GetInstance(this.commandName); if (instance == null) { return(result); } WildcardPattern pattern = new WildcardPattern(instance.ShortName, WildcardOptions.IgnoreCase); foreach (List <CmdletInfo> list in this._context.EngineSessionState.GetCmdletTable().Values) { foreach (CmdletInfo info2 in list) { if (pattern.IsMatch(info2.Name) && (string.IsNullOrEmpty(instance.PSSnapInName) || instance.PSSnapInName.Equals(info2.ModuleName, StringComparison.OrdinalIgnoreCase))) { collection.Add(info2); } } } this.matchingCmdlet = collection.GetEnumerator(); } else { this.matchingCmdlet = this._context.CommandDiscovery.GetCmdletInfo(this.commandName, (this.commandResolutionOptions & SearchResolutionOptions.SearchAllScopes) != SearchResolutionOptions.None); } } if (!this.matchingCmdlet.MoveNext()) { this.currentState = SearchState.SearchingBuiltinScripts; this.matchingCmdlet = null; } else { result = this.matchingCmdlet.Current; } return(traceResult(result)); }
internal static PSSnapinQualifiedName GetInstance(string name) { if (name == null) { return null; } PSSnapinQualifiedName name2 = null; string[] splitName = name.Split(new char[] { '\\' }); if ((splitName.Length < 0) || (splitName.Length > 2)) { return null; } name2 = new PSSnapinQualifiedName(splitName); if (string.IsNullOrEmpty(name2.ShortName)) { return null; } return name2; }
internal static PSSnapinQualifiedName GetInstance(string name) { if (name == null) { return(null); } PSSnapinQualifiedName name2 = null; string[] splitName = name.Split(new char[] { '\\' }); if ((splitName.Length < 0) || (splitName.Length > 2)) { return(null); } name2 = new PSSnapinQualifiedName(splitName); if (string.IsNullOrEmpty(name2.ShortName)) { return(null); } return(name2); }
internal static PSSnapinQualifiedName?GetInstance(string?name) { if (name is null) { return(null); } string[] splitName = name.Split(Utils.Separators.Backslash); if (splitName.Length == 0 || splitName.Length > 2) { return(null); } var result = new PSSnapinQualifiedName(splitName); // If the shortname is empty, then return null... if (string.IsNullOrEmpty(result.ShortName)) { return(null); } return(result); }
internal bool IsMatch(WildcardPattern namePattern, PSSnapinQualifiedName psSnapinQualifiedName) { bool flag = false; if (psSnapinQualifiedName == null) { return(true); } if (namePattern == null) { if (string.Equals(this.Name, psSnapinQualifiedName.ShortName, StringComparison.OrdinalIgnoreCase) && this.IsPSSnapinNameMatch(psSnapinQualifiedName)) { flag = true; } return(flag); } if (namePattern.IsMatch(this.Name) && this.IsPSSnapinNameMatch(psSnapinQualifiedName)) { flag = true; } return(flag); }
internal Collection <CmdletInfo> GetCmdletInfo(string cmdletName) { PSSnapinQualifiedName instance = PSSnapinQualifiedName.GetInstance(cmdletName); return(instance == null ? new Collection <CmdletInfo>() : this.GetCmdletInfo(instance)); }
private bool IsPSSnapinNameMatch(PSSnapinQualifiedName psSnapinQualifiedName) { bool flag = false; if (!string.IsNullOrEmpty(psSnapinQualifiedName.PSSnapInName) && !string.Equals(psSnapinQualifiedName.PSSnapInName, this.PSSnapInName, StringComparison.OrdinalIgnoreCase)) { return flag; } return true; }
internal bool IsMatch(WildcardPattern namePattern, PSSnapinQualifiedName psSnapinQualifiedName) { bool flag = false; if (psSnapinQualifiedName == null) { return true; } if (namePattern == null) { if (string.Equals(this.Name, psSnapinQualifiedName.ShortName, StringComparison.OrdinalIgnoreCase) && this.IsPSSnapinNameMatch(psSnapinQualifiedName)) { flag = true; } return flag; } if (namePattern.IsMatch(this.Name) && this.IsPSSnapinNameMatch(psSnapinQualifiedName)) { flag = true; } return flag; }
/// <summary> /// Search for provider help based on a search target. /// </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></returns> internal override IEnumerable <HelpInfo> SearchHelp(HelpRequest helpRequest, bool searchOnlyContent) { int countOfHelpInfoObjectsFound = 0; string target = helpRequest.Target; string pattern = target; // this will be used only when searchOnlyContent == true WildcardPattern wildCardPattern = null; bool decoratedSearch = !WildcardPattern.ContainsWildcardCharacters(target); if (!searchOnlyContent) { if (decoratedSearch) { pattern += "*"; } } else { string searchTarget = helpRequest.Target; if (decoratedSearch) { searchTarget = "*" + helpRequest.Target + "*"; } wildCardPattern = WildcardPattern.Get(searchTarget, WildcardOptions.Compiled | WildcardOptions.IgnoreCase); // search in all providers pattern = "*"; } PSSnapinQualifiedName snapinQualifiedNameForPattern = PSSnapinQualifiedName.GetInstance(pattern); if (null == snapinQualifiedNameForPattern) { yield break; } foreach (ProviderInfo providerInfo in _sessionState.Provider.GetAll()) { if (providerInfo.IsMatch(pattern)) { try { LoadHelpFile(providerInfo); } catch (IOException ioException) { if (!decoratedSearch) { ReportHelpFileError(ioException, providerInfo.Name, providerInfo.HelpFile); } } catch (System.Security.SecurityException securityException) { if (!decoratedSearch) { ReportHelpFileError(securityException, providerInfo.Name, providerInfo.HelpFile); } } catch (XmlException xmlException) { if (!decoratedSearch) { ReportHelpFileError(xmlException, providerInfo.Name, providerInfo.HelpFile); } } HelpInfo helpInfo = GetCache(providerInfo.PSSnapInName + "\\" + providerInfo.Name); if (helpInfo != null) { if (searchOnlyContent) { // ignore help objects that do not have pattern in its help // content. if (!helpInfo.MatchPatternInContent(wildCardPattern)) { continue; } } countOfHelpInfoObjectsFound++; yield return(helpInfo); if (countOfHelpInfoObjectsFound >= helpRequest.MaxResults && helpRequest.MaxResults > 0) { yield break; } } } } }
private CmdletInfo GetNextCmdlet() { CmdletInfo result = (CmdletInfo)null; if (this.matchingCmdlet == null) { Collection <CmdletInfo> matchingCmdlets; if ((this.commandResolutionOptions & SearchResolutionOptions.CommandNameIsPattern) != SearchResolutionOptions.None) { matchingCmdlets = new Collection <CmdletInfo>(); PSSnapinQualifiedName instance = PSSnapinQualifiedName.GetInstance(this.commandName); if (instance == null) { return(result); } WildcardPattern wildcardPattern = new WildcardPattern(instance.ShortName, WildcardOptions.IgnoreCase); Dictionary <string, List <CmdletInfo> > cmdletCache = this._context.EngineSessionState.CmdletCache; while (true) { lock (cmdletCache) { foreach (List <CmdletInfo> cmdletInfoList in cmdletCache.Values) { foreach (CmdletInfo cmdletInfo in cmdletInfoList) { if (wildcardPattern.IsMatch(cmdletInfo.Name) && (string.IsNullOrEmpty(instance.PSSnapInName) || instance.PSSnapInName.Equals(cmdletInfo.ModuleName, StringComparison.OrdinalIgnoreCase))) { matchingCmdlets.Add(cmdletInfo); } } } } if (cmdletCache != this._context.TopLevelSessionState.CmdletCache) { cmdletCache = this._context.TopLevelSessionState.CmdletCache; } else { break; } } } else { matchingCmdlets = this._context.CommandDiscovery.GetCmdletInfo(this.commandName); if (matchingCmdlets.Count > 1) { if ((this.commandResolutionOptions & SearchResolutionOptions.ReturnFirstDuplicateCmdletName) != SearchResolutionOptions.None) { this.matchingCmdlet = matchingCmdlets.GetEnumerator(); while (this.matchingCmdlet.MoveNext()) { if (result == null) { result = this.matchingCmdlet.Current; } } return(this.traceResult(result)); } if ((this.commandResolutionOptions & SearchResolutionOptions.AllowDuplicateCmdletNames) == SearchResolutionOptions.None) { throw this.NewAmbiguousCmdletName(this.commandName, matchingCmdlets); } } } this.matchingCmdlet = matchingCmdlets.GetEnumerator(); } if (!this.matchingCmdlet.MoveNext()) { this.currentState = CommandSearcher.SearchState.CmdletResolution; this.matchingCmdlet = (IEnumerator <CmdletInfo>)null; } else { result = this.matchingCmdlet.Current; } return(this.traceResult(result)); }
internal Collection<ProviderInfo> GetProvider(PSSnapinQualifiedName providerName) { Collection<ProviderInfo> collection = new Collection<ProviderInfo>(); if (providerName == null) { ProviderNotFoundException exception = new ProviderNotFoundException(providerName.ToString(), SessionStateCategory.CmdletProvider, "ProviderNotFound", SessionStateStrings.ProviderNotFound, new object[0]); throw exception; } string pName = null; List<ProviderInfo> list = null; if (!this.Providers.TryGetValue(providerName.ShortName, out list)) { MountDefaultDrive(providerName.ShortName, this._context); pName = (OSHelper.IsUnix && providerName.ShortName == "/") ? "FileSystem" : providerName.ShortName; if (pName == "env") { pName = "Environment"; } else if (pName == "cert") { pName = "Certificate"; } else if (pName == "reg") { pName = "Registry"; } if (!this.Providers.TryGetValue(pName, out list)) { ProviderNotFoundException exception2 = new ProviderNotFoundException(providerName.ToString(), SessionStateCategory.CmdletProvider, "ProviderNotFound", SessionStateStrings.ProviderNotFound, new object[0]); throw exception2; } } if (string.IsNullOrEmpty (pName)) pName = providerName.PSSnapInName; if (this.ExecutionContext.IsSingleShell && !string.IsNullOrEmpty(providerName.PSSnapInName)) { foreach (ProviderInfo info in list) { if (string.Equals(info.PSSnapInName, pName, StringComparison.OrdinalIgnoreCase) || string.Equals(info.ModuleName, pName, StringComparison.OrdinalIgnoreCase)) { collection.Add(info); } } return collection; } foreach (ProviderInfo info2 in list) { collection.Add(info2); } return collection; }
internal Collection<ProviderInfo> GetProvider(PSSnapinQualifiedName providerName) { Collection<ProviderInfo> result = new Collection<ProviderInfo>(); if (providerName == null) { ProviderNotFoundException e = new ProviderNotFoundException( providerName.ToString(), SessionStateCategory.CmdletProvider, "ProviderNotFound", SessionStateStrings.ProviderNotFound); throw e; } // Get the provider from the providers container List<ProviderInfo> matchingProviders = null; if (!Providers.TryGetValue(providerName.ShortName, out matchingProviders)) { // If the provider was not found, we may need to auto-mount it. SessionStateInternal.MountDefaultDrive(providerName.ShortName, ExecutionContext); if (!Providers.TryGetValue(providerName.ShortName, out matchingProviders)) { ProviderNotFoundException e = new ProviderNotFoundException( providerName.ToString(), SessionStateCategory.CmdletProvider, "ProviderNotFound", SessionStateStrings.ProviderNotFound); throw e; } } if (ExecutionContext.IsSingleShell && !String.IsNullOrEmpty(providerName.PSSnapInName)) { // Be sure the PSSnapin/Module name matches foreach (ProviderInfo provider in matchingProviders) { if (String.Equals( provider.PSSnapInName, providerName.PSSnapInName, StringComparison.OrdinalIgnoreCase) || String.Equals( provider.ModuleName, providerName.PSSnapInName, StringComparison.OrdinalIgnoreCase)) { result.Add(provider); } } } else { foreach (ProviderInfo provider in matchingProviders) { result.Add(provider); } } return result; } // GetProvider
private bool IsPSSnapinNameMatch(PSSnapinQualifiedName psSnapinQualifiedName) { bool result = false; if (String.IsNullOrEmpty(psSnapinQualifiedName.PSSnapInName) || String.Equals(psSnapinQualifiedName.PSSnapInName, PSSnapInName, StringComparison.OrdinalIgnoreCase)) { result = true; } return result; }
internal bool IsMatch(WildcardPattern namePattern, PSSnapinQualifiedName psSnapinQualifiedName) { bool result = false; if (psSnapinQualifiedName == null) { result = true; } else { if (namePattern == null) { if (String.Equals(Name, psSnapinQualifiedName.ShortName, StringComparison.OrdinalIgnoreCase) && IsPSSnapinNameMatch(psSnapinQualifiedName)) { result = true; } } else if (namePattern.IsMatch(Name) && IsPSSnapinNameMatch(psSnapinQualifiedName)) { result = true; } } return result; }
internal CommandAndName(PSObject command, PSSnapinQualifiedName commandName) { this.Command = command; this.CommandName = commandName; }
internal override IEnumerable <HelpInfo> SearchHelp( HelpRequest helpRequest, bool searchOnlyContent) { using (ProviderHelpProvider.tracer.TraceMethod()) { int countOfHelpInfoObjectsFound = 0; string target = helpRequest.Target; string pattern = target; WildcardPattern wildCardPattern = (WildcardPattern)null; bool decoratedSearch = !WildcardPattern.ContainsWildcardCharacters(target); if (!searchOnlyContent) { if (decoratedSearch) { // ISSUE: reference to a compiler-generated field this.\u003Cpattern\u003E5__d += "*"; } } else { string pattern1 = helpRequest.Target; if (decoratedSearch) { pattern1 = "*" + helpRequest.Target + "*"; } wildCardPattern = new WildcardPattern(pattern1, WildcardOptions.Compiled | WildcardOptions.IgnoreCase); pattern = "*"; } PSSnapinQualifiedName snapinQualifiedNameForPattern = PSSnapinQualifiedName.GetInstance(pattern); if (snapinQualifiedNameForPattern != null) { foreach (ProviderInfo providerInfo in this._sessionState.Provider.GetAll()) { if (providerInfo.IsMatch(pattern)) { try { this.LoadHelpFile(providerInfo); } catch (IOException ex) { if (!decoratedSearch) { this.ReportHelpFileError((Exception)ex, providerInfo.Name, providerInfo.HelpFile); } } catch (SecurityException ex) { if (!decoratedSearch) { this.ReportHelpFileError((Exception)ex, providerInfo.Name, providerInfo.HelpFile); } } catch (XmlException ex) { if (!decoratedSearch) { this.ReportHelpFileError((Exception)ex, providerInfo.Name, providerInfo.HelpFile); } } HelpInfo helpInfo = this.GetCache(providerInfo.PSSnapInName + "\\" + providerInfo.Name); if (helpInfo != null && (!searchOnlyContent || helpInfo.MatchPatternInContent(wildCardPattern))) { ++countOfHelpInfoObjectsFound; yield return(helpInfo); if (countOfHelpInfoObjectsFound >= helpRequest.MaxResults && helpRequest.MaxResults > 0) { break; } } } } } } }
internal override IEnumerable <HelpInfo> SearchHelp(HelpRequest helpRequest, bool searchOnlyContent) { int iteratorVariable0 = 0; string pattern = helpRequest.Target; string name = pattern; WildcardPattern iteratorVariable3 = null; bool iteratorVariable4 = !WildcardPattern.ContainsWildcardCharacters(pattern); if (!searchOnlyContent) { if (iteratorVariable4) { name = name + "*"; } } else { string target = helpRequest.Target; if (iteratorVariable4) { target = "*" + helpRequest.Target + "*"; } iteratorVariable3 = new WildcardPattern(target, WildcardOptions.IgnoreCase | WildcardOptions.Compiled); name = "*"; } PSSnapinQualifiedName instance = PSSnapinQualifiedName.GetInstance(name); if (instance != null) { foreach (ProviderInfo iteratorVariable6 in this._sessionState.Provider.GetAll()) { if (!iteratorVariable6.IsMatch(name)) { continue; } try { this.LoadHelpFile(iteratorVariable6); } catch (IOException exception) { if (!iteratorVariable4) { this.ReportHelpFileError(exception, iteratorVariable6.Name, iteratorVariable6.HelpFile); } } catch (SecurityException exception2) { if (!iteratorVariable4) { this.ReportHelpFileError(exception2, iteratorVariable6.Name, iteratorVariable6.HelpFile); } } catch (XmlException exception3) { if (!iteratorVariable4) { this.ReportHelpFileError(exception3, iteratorVariable6.Name, iteratorVariable6.HelpFile); } } HelpInfo cache = this.GetCache(iteratorVariable6.PSSnapInName + @"\" + iteratorVariable6.Name); if ((cache != null) && (!searchOnlyContent || cache.MatchPatternInContent(iteratorVariable3))) { iteratorVariable0++; yield return(cache); if ((iteratorVariable0 >= helpRequest.MaxResults) && (helpRequest.MaxResults > 0)) { break; } } } } }