当前位置: 首页>>代码示例>>C#>>正文


C# Automation.WildcardPattern类代码示例

本文整理汇总了C#中System.Management.Automation.WildcardPattern的典型用法代码示例。如果您正苦于以下问题:C# WildcardPattern类的具体用法?C# WildcardPattern怎么用?C# WildcardPattern使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


WildcardPattern类属于System.Management.Automation命名空间,在下文中一共展示了WildcardPattern类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FilterElements

 internal override List<IUiElement> FilterElements(SingleControlSearcherData controlSearcherData, List<IUiElement> initialCollection)
 {
     const WildcardOptions options = WildcardOptions.IgnoreCase | WildcardOptions.Compiled;
     var wildcardName = new WildcardPattern(controlSearcherData.Name ?? "*", options);
     var wildcardValue = new WildcardPattern(controlSearcherData.Value ?? "*", options);
     
     foreach (IUiElement element in initialCollection) {
         if (element.IsMatchWildcardPattern(ResultCollection, wildcardName, element.GetCurrent().Name))
             continue;
         if (element.IsMatchWildcardPattern(ResultCollection, wildcardName, element.GetCurrent().AutomationId))
             continue;
         if (element.IsMatchWildcardPattern(ResultCollection, wildcardName, element.GetCurrent().ClassName))
             continue;
         try {
             string elementValue = element.GetCurrentPattern<IValuePattern>(classic.ValuePattern.Pattern).Current.Value;
             if (element.IsMatchWildcardPattern(ResultCollection, wildcardName, elementValue))
                 continue;
             if (element.IsMatchWildcardPattern(ResultCollection, wildcardValue, elementValue))
                 continue;
         } catch {
         }
     }
     
     return ResultCollection;
 }
开发者ID:MatkoHanus,项目名称:STUPS,代码行数:25,代码来源:ControlFromWin32Provider.cs

示例2: GetRoleNames

        // Returns a RoleNamesCollection based on instances in the roleInstanceList
        // whose RoleInstance.RoleName matches the roleName passed in.  Wildcards
        // are handled for the roleName passed in.
        // This function also verifies that the RoleInstance exists before adding the
        // RoleName to the RoleNamesCollection.
        public static RoleNamesCollection GetRoleNames(RoleInstanceList roleInstanceList, string roleName)
        {
            var roleNamesCollection = new RoleNamesCollection();
            if (!string.IsNullOrEmpty(roleName))
            {
                if (WildcardPattern.ContainsWildcardCharacters(roleName))
                {
                    WildcardOptions wildcardOptions = WildcardOptions.IgnoreCase | WildcardOptions.Compiled;
                    WildcardPattern wildcardPattern = new WildcardPattern(roleName, wildcardOptions);

                    foreach (RoleInstance role in roleInstanceList)
                        if (!string.IsNullOrEmpty(role.RoleName) && wildcardPattern.IsMatch(role.RoleName))
                        {
                            roleNamesCollection.Add(role.RoleName);
                        }
                }
                else
                {
                    var roleInstance = roleInstanceList.Where(r => r.RoleName != null).
                        FirstOrDefault(r => r.RoleName.Equals(roleName, StringComparison.InvariantCultureIgnoreCase));
                    if (roleInstance != null)
                    {
                        roleNamesCollection.Add(roleName);
                    }
                }
            }
            return roleNamesCollection;
        }
开发者ID:nazang,项目名称:azure-sdk-tools,代码行数:33,代码来源:PersistentVMHelper.cs

示例3: WildcardPattern

		public virtual IUiEltCollection this[string infoString]
        {
            get
            {
                if (string.IsNullOrEmpty(infoString)) return null;
                
                try {
                    
                    if (null == this || 0 == this.Count) return null;
                    
                    const WildcardOptions options = WildcardOptions.IgnoreCase |
                                                    WildcardOptions.Compiled;
                    
                    var wildcardInfoString = 
                        new WildcardPattern(infoString, options);
                    
                    var queryByStringData = from collectionItem
                        in this._collectionHolder //.ToArray()
                            where wildcardInfoString.IsMatch(collectionItem.GetCurrent().Name) ||
                        wildcardInfoString.IsMatch(collectionItem.GetCurrent().AutomationId) ||
                        wildcardInfoString.IsMatch(collectionItem.GetCurrent().ClassName)
                        select collectionItem;
                    
                    return AutomationFactory.GetUiEltCollection(queryByStringData);
                }
                catch {
                    return null;
                    // return new IUiElement[] {};
                }
            }
        }
开发者ID:universsky,项目名称:STUPS,代码行数:31,代码来源:UiEltCollection.cs

示例4: GetParameter

 internal override PSObject[] GetParameter(string pattern)
 {
     if (((this.FullHelp == null) || (this.FullHelp.Properties["parameters"] == null)) || (this.FullHelp.Properties["parameters"].Value == null))
     {
         return base.GetParameter(pattern);
     }
     PSObject obj2 = PSObject.AsPSObject(this.FullHelp.Properties["parameters"].Value);
     if (obj2.Properties["parameter"] == null)
     {
         return base.GetParameter(pattern);
     }
     PSObject[] objArray = (PSObject[]) LanguagePrimitives.ConvertTo(obj2.Properties["parameter"].Value, typeof(PSObject[]), CultureInfo.InvariantCulture);
     if (string.IsNullOrEmpty(pattern))
     {
         return objArray;
     }
     List<PSObject> list = new List<PSObject>();
     WildcardPattern pattern2 = new WildcardPattern(pattern, WildcardOptions.IgnoreCase);
     foreach (PSObject obj3 in objArray)
     {
         if ((obj3.Properties["name"] != null) && (obj3.Properties["name"].Value != null))
         {
             string input = obj3.Properties["name"].Value.ToString();
             if (pattern2.IsMatch(input))
             {
                 list.Add(obj3);
             }
         }
     }
     return list.ToArray();
 }
开发者ID:nickchal,项目名称:pash,代码行数:31,代码来源:BaseCommandHelpInfo.cs

示例5: AddWildcardDynamicMembers

        IEnumerable<DynamicMemberDescriptor> AddWildcardDynamicMembers(DynamicMemberSpecification spec, WildcardPattern pattern, PSObject ps, string proxyPropertyName)
        {
            var props = ps.Properties;
            var scriptFormat = "$this.'{0}'";
            if (null != proxyPropertyName)
            {
                props = ps.Properties[proxyPropertyName].ToPSObject().Properties;
                scriptFormat = "$this.'{1}'.'{0}'";
            }
            var matchingPropertyNames = from prop in props
                                        where pattern.IsMatch(prop.Name)
                                        select prop.Name;

            var members = matchingPropertyNames.ToList().ConvertAll(
                s => new
                {
                    PropertyName = s,
                    Member = new PSScriptProperty(
                         (proxyPropertyName ?? "" ) + "_" + s,
                         System.Management.Automation.ScriptBlock.Create(String.Format(scriptFormat, s,
                                                                                       proxyPropertyName))
                         )
                });
            return (from m in members
                    let s = (from sd in spec.ScaleDescriptors
                                 where sd.Key.IsMatch(m.PropertyName)
                                 select sd.Value).FirstOrDefault()
                    select new DynamicMemberDescriptor(m.Member, s)).ToList();
        }
开发者ID:powercode,项目名称:seeshell,代码行数:29,代码来源:DynamicMemberFactory.cs

示例6: ExpandPath

 protected override string[] ExpandPath(string path)
 {
     var wildcard = new WildcardPattern(path, WildcardOptions.IgnoreCase);
     return (from i in _defaultDrive.Items.Keys
                      where wildcard.IsMatch(i)
                      select i).ToArray();
 }
开发者ID:bitwiseman,项目名称:Pash,代码行数:7,代码来源:TestItemProvider.cs

示例7: ProcessProviderOperationsWithWildCard

        /// <summary>
        /// Get a list of Provider operations in the case that the Actionstring input contains a wildcard
        /// </summary>
        private List<PSResourceProviderOperation> ProcessProviderOperationsWithWildCard(string actionString)
        {
            // Filter the list of all operation names to what matches the wildcard
            WildcardPattern wildcard = new WildcardPattern(actionString, WildcardOptions.IgnoreCase | WildcardOptions.Compiled);

            List<ProviderOperationsMetadata> providers = new List<ProviderOperationsMetadata>();

            string nonWildCardPrefix = GetAzureProviderOperationCommand.GetNonWildcardPrefix(actionString);
            if (string.IsNullOrWhiteSpace(nonWildCardPrefix))
            {
                // 'Get-AzureProviderOperation *' or 'Get-AzureProviderOperation */virtualmachines/*'
                // get operations for all providers
                providers.AddRange(this.ResourcesClient.ListProviderOperationsMetadata());
            }
            else
            {
                // Some string exists before the wild card character - potentially the full name of the provider.
                string providerFullName = GetAzureProviderOperationCommand.GetResourceProviderFullName(nonWildCardPrefix);
                if (!string.IsNullOrWhiteSpace(providerFullName))
                {
                    // we have the full name of the provider. 'Get-AzureProviderOperation Microsoft.Sql/servers/*'
                    // only query for that provider
                    providers.Add(this.ResourcesClient.GetProviderOperationsMetadata(providerFullName));
                }
                else
                {
                    // We have only a partial name of the provider, say Microsoft.*/* or Microsoft.*/*/read.
                    // query for all providers and then do prefix match on the operations
                    providers.AddRange(this.ResourcesClient.ListProviderOperationsMetadata());
                }
            }

            return providers.SelectMany(p => GetPSOperationsFromProviderOperationsMetadata(p)).Where(operation => wildcard.IsMatch(operation.Operation)).ToList();            
        }
开发者ID:nityasharma,项目名称:azure-powershell,代码行数:37,代码来源:GetAzureProviderOperationCmdlet.cs

示例8: GetLoadedModulesByWildcard

 private IEnumerable<PSModuleInfo> GetLoadedModulesByWildcard(string wildcardStr)
 {
     var wildcard = new WildcardPattern(wildcardStr, WildcardOptions.IgnoreCase);
     var modules = from modPair in ExecutionContext.SessionState.LoadedModules.GetAll()
         where wildcard.IsMatch(modPair.Value.Name) select modPair.Value;
     return modules;
 }
开发者ID:mauve,项目名称:Pash,代码行数:7,代码来源:RemoveModuleCommand.cs

示例9: ProcessRecord

        protected override void ProcessRecord()
        {
            if (String.IsNullOrEmpty(Property))
            {
                if (Object == null)
                {
                    WriteObject(_existingProperties, true);
                }
                else
                {
                    WriteObject(Object.Properties, true);
                }
                return;
            }

            var wildcard = new WildcardPattern(Property + "*", WildcardOptions.IgnoreCase);
            if (Object == null)
            {
                WriteObject(from pair in _existingProperties
                            where wildcard.IsMatch(pair.Key)
                            select pair.Value, true);
            }
            else
            {
                WriteObject(from prop in Object.Properties
                            where wildcard.IsMatch(prop.LocalName)
                            select prop, true);
            }
        }
开发者ID:OpenDataSpace,项目名称:CmisCmdlets,代码行数:29,代码来源:GetCmisPropertyCommand.cs

示例10: Parse

 public static void Parse(WildcardPattern pattern, WildcardPatternParser parser)
 {
     parser.BeginWildcardPattern(pattern);
     bool flag = false;
     bool flag2 = false;
     bool flag3 = false;
     StringBuilder builder = null;
     StringBuilder builder2 = null;
     foreach (char ch in pattern.Pattern)
     {
         if (flag3)
         {
             if (((ch == ']') && !flag2) && !flag)
             {
                 flag3 = false;
                 parser.AppendBracketExpression(builder.ToString(), builder2.ToString(), pattern.Pattern);
                 builder = null;
                 builder2 = null;
             }
             else if ((ch != '`') || flag)
             {
                 builder.Append(ch);
                 builder2.Append(((ch == '-') && !flag) ? '-' : ' ');
             }
             flag2 = false;
         }
         else if ((ch == '*') && !flag)
         {
             parser.AppendAsterix();
         }
         else if ((ch == '?') && !flag)
         {
             parser.AppendQuestionMark();
         }
         else if ((ch == '[') && !flag)
         {
             flag3 = true;
             builder = new StringBuilder();
             builder2 = new StringBuilder();
             flag2 = true;
         }
         else if ((ch != '`') || flag)
         {
             parser.AppendLiteralCharacter(ch);
         }
         flag = (ch == '`') && !flag;
     }
     if (flag3)
     {
         throw NewWildcardPatternException(pattern.Pattern);
     }
     if (flag && !pattern.Pattern.Equals("`", StringComparison.Ordinal))
     {
         parser.AppendLiteralCharacter(pattern.Pattern[pattern.Pattern.Length - 1]);
     }
     parser.EndWildcardPattern();
 }
开发者ID:nickchal,项目名称:pash,代码行数:57,代码来源:WildcardPatternParser.cs

示例11: GetWildcardPattern

 protected static WildcardPattern GetWildcardPattern(string name)
 {
     if (String.IsNullOrEmpty(name))
     {
         name = "*";
     }
     const WildcardOptions options = WildcardOptions.IgnoreCase | WildcardOptions.Compiled;
     var wildcard = new WildcardPattern(name, options);
     return wildcard;
 }
开发者ID:sobek85,项目名称:Console,代码行数:10,代码来源:PsSitecoreItemProvider.cs

示例12: EndProcessing

        protected override void EndProcessing()
        {
            try
            {
                Predicate<string> IsMatch;

                // name provided?
                if (!String.IsNullOrEmpty(this.Name))
                {
                    // Need an explicit wildcard match?
                    if (WildcardPattern.ContainsWildcardCharacters(this.Name))
                    {
                        // yes, the user provided some wildcard characters
                        var pattern = new WildcardPattern(this.Name, WildcardOptions.IgnoreCase);

                        // use method group (delegate inference) for pattern match
                        IsMatch = pattern.IsMatch;
                    }
                    else
                    {
                        // use lambda for implicit wildcard matching - the user most likely
                        // is not looking for an exact match, so treat it as a substring search.
                        IsMatch = (name => (name.IndexOf(this.Name, 0, StringComparison.OrdinalIgnoreCase) != -1));
                    }
                }
                else
                {
                    // return all
                    IsMatch = delegate { return true; };
                }

                // Dump out installed data providers available to .NET
                foreach (DataRow factory in DbProviderFactories.GetFactoryClasses().Rows)
                {
                    var name = (string) factory["InvariantName"];
                    var displayName = (string) factory["Name"];
                    var description = (string) factory["Description"];

                    if (IsMatch(name))
                    {
                        var factoryInfo = new PSObject();

                        factoryInfo.Properties.Add(new PSNoteProperty("ProviderName", name));
                        factoryInfo.Properties.Add(new PSNoteProperty("DisplayName", displayName));
                        factoryInfo.Properties.Add(new PSNoteProperty("Description", description));

                        WriteObject(factoryInfo);
                    }
                }
            }
            finally
            {
                base.EndProcessing();
            }
        }
开发者ID:razaraz,项目名称:Pscx,代码行数:55,代码来源:GetAdoDataProviderCommand.cs

示例13: GetPSSnapIns

 internal Collection<PSSnapInInfo> GetPSSnapIns(WildcardPattern wildcard)
 {
     Collection<PSSnapInInfo> matches = new Collection<PSSnapInInfo>();
     foreach (var pair in _snapins)
     {
         if (wildcard.IsMatch(pair.Key))
         {
             matches.Add(pair.Value);
         }
     }
     return matches;
 }
开发者ID:mauve,项目名称:Pash,代码行数:12,代码来源:SessionStateGlobal.cs

示例14: Match

 private static bool Match(string target, string pattern)
 {
     if (string.IsNullOrEmpty(pattern))
     {
         return true;
     }
     if (string.IsNullOrEmpty(target))
     {
         target = "";
     }
     WildcardPattern pattern2 = new WildcardPattern(pattern, WildcardOptions.IgnoreCase);
     return pattern2.IsMatch(target);
 }
开发者ID:nickchal,项目名称:pash,代码行数:13,代码来源:AliasHelpProvider.cs

示例15: GetSnapIns

 protected internal Collection<PSSnapInInfo> GetSnapIns(string pattern)
 {
     if (this.Runspace != null)
     {
         if (pattern != null)
         {
             return this.Runspace.ConsoleInfo.GetPSSnapIn(pattern, this._shouldGetAll);
         }
         return this.Runspace.ConsoleInfo.PSSnapIns;
     }
     WildcardPattern pattern2 = null;
     if (!string.IsNullOrEmpty(pattern))
     {
         if (!WildcardPattern.ContainsWildcardCharacters(pattern))
         {
             PSSnapInInfo.VerifyPSSnapInFormatThrowIfError(pattern);
         }
         pattern2 = new WildcardPattern(pattern, WildcardOptions.IgnoreCase);
     }
     Collection<PSSnapInInfo> collection = new Collection<PSSnapInInfo>();
     if (this._shouldGetAll)
     {
         foreach (PSSnapInInfo info in PSSnapInReader.ReadAll())
         {
             if ((pattern2 == null) || pattern2.IsMatch(info.Name))
             {
                 collection.Add(info);
             }
         }
         return collection;
     }
     List<CmdletInfo> cmdlets = base.InvokeCommand.GetCmdlets();
     Dictionary<PSSnapInInfo, bool> dictionary = new Dictionary<PSSnapInInfo, bool>();
     foreach (CmdletInfo info2 in cmdlets)
     {
         PSSnapInInfo pSSnapIn = info2.PSSnapIn;
         if ((pSSnapIn != null) && !dictionary.ContainsKey(pSSnapIn))
         {
             dictionary.Add(pSSnapIn, true);
         }
     }
     foreach (PSSnapInInfo info4 in dictionary.Keys)
     {
         if ((pattern2 == null) || pattern2.IsMatch(info4.Name))
         {
             collection.Add(info4);
         }
     }
     return collection;
 }
开发者ID:nickchal,项目名称:pash,代码行数:50,代码来源:PSSnapInCommandBase.cs


注:本文中的System.Management.Automation.WildcardPattern类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。