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


C# WildcardPattern.IsMatch方法代码示例

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


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

示例1: 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

示例2: 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

示例3: ProcessRecord

 protected override void ProcessRecord()
 {
    string[] templateFiles = XamlHelper.GetDataTemplates();
    foreach (string path in Filter)
    {
       var pat = new WildcardPattern(path);
       foreach (var file in templateFiles)
       {
          if (pat.IsMatch(file) || pat.IsMatch( Path.GetDirectoryName(file) ))
          {
             WriteObject(new FileInfo(file));
          }
       }
    }
 }
开发者ID:ForNeVeR,项目名称:PoshConsole,代码行数:15,代码来源:UITemplate-Get-Command.cs

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: MatchPatternInContent

 internal override bool MatchPatternInContent(WildcardPattern pattern)
 {
     string synopsis = this.Synopsis;
     string answers = this.Answers;
     if (synopsis == null)
     {
         synopsis = string.Empty;
     }
     if (this.Answers == null)
     {
         answers = string.Empty;
     }
     if (!pattern.IsMatch(synopsis))
     {
         return pattern.IsMatch(answers);
     }
     return true;
 }
开发者ID:nickchal,项目名称:pash,代码行数:18,代码来源:FaqHelpInfo.cs

示例10: MatchPatternInContent

 internal override bool MatchPatternInContent(WildcardPattern pattern)
 {
     string synopsis = this.Synopsis;
     string detailedDescription = this.DetailedDescription;
     if (synopsis == null)
     {
         synopsis = string.Empty;
     }
     if (detailedDescription == null)
     {
         detailedDescription = string.Empty;
     }
     if (!pattern.IsMatch(synopsis))
     {
         return pattern.IsMatch(detailedDescription);
     }
     return true;
 }
开发者ID:nickchal,项目名称:pash,代码行数:18,代码来源:ProviderHelpInfo.cs

示例11: GetMatchingTraceSource

 internal Collection<PSTraceSource> GetMatchingTraceSource(string[] patternsToMatch, bool writeErrorIfMatchNotFound, out Collection<string> notMatched)
 {
     notMatched = new Collection<string>();
     Collection<PSTraceSource> collection = new Collection<PSTraceSource>();
     foreach (string str in patternsToMatch)
     {
         bool flag = false;
         if (string.IsNullOrEmpty(str))
         {
             notMatched.Add(str);
         }
         else
         {
             WildcardPattern pattern = new WildcardPattern(str, WildcardOptions.IgnoreCase);
             foreach (PSTraceSource source in PSTraceSource.TraceCatalog.Values)
             {
                 if (pattern.IsMatch(source.FullName))
                 {
                     flag = true;
                     collection.Add(source);
                 }
                 else if (pattern.IsMatch(source.Name))
                 {
                     flag = true;
                     collection.Add(source);
                 }
             }
             if (!flag)
             {
                 notMatched.Add(str);
                 if (writeErrorIfMatchNotFound && !WildcardPattern.ContainsWildcardCharacters(str))
                 {
                     ItemNotFoundException replaceParentContainsErrorRecordException = new ItemNotFoundException(str, "TraceSourceNotFound", SessionStateStrings.TraceSourceNotFound);
                     ErrorRecord errorRecord = new ErrorRecord(replaceParentContainsErrorRecordException.ErrorRecord, replaceParentContainsErrorRecordException);
                     base.WriteError(errorRecord);
                 }
             }
         }
     }
     return collection;
 }
开发者ID:nickchal,项目名称:pash,代码行数:41,代码来源:TraceCommandBase.cs

示例12: 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

示例13: 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

示例14: ProcessRecord

        protected override void ProcessRecord()
        {
            if (Id.HasValue)
            {
                WriteObject(_controller.GetDevice(Id.Value));
            }
            else
            {
                var wildCard = new WildcardPattern(Name, WildcardOptions.IgnoreCase);

                WriteObject(
                    _controller.GetDevices()
                        .FirstOrDefault(x => wildCard.IsMatch(x.Name)));
            }
        }
开发者ID:cdhunt,项目名称:AudioSwitcher,代码行数:15,代码来源:GetAudioDevice.cs

示例15: Extract

 internal void Extract(string entryPath)
 {
     if (WildcardPattern.ContainsWildcardCharacters(entryPath))
     {
         Command.WriteVerbose("Using wildcard extraction.");
         var pattern = new WildcardPattern(entryPath, WildcardOptions.IgnoreCase);
         Extract(entry => pattern.IsMatch(entry.Path));
     }
     else
     {
         // todo: fix ignorecase
         Extract(entry => entry.Path.Equals(entryPath,
             StringComparison.OrdinalIgnoreCase));
     }
 }
开发者ID:nickchal,项目名称:pash,代码行数:15,代码来源:PscxSevenZipExtractor.cs


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