• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Automation.WildcardPattern类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


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


示例17: BeginProcessing

        /// <summary>
        /// Creates a list of property name wildcard patterns.
        /// </summary>
        protected override void BeginProcessing()
        {
            var count = this.Property.Count();
            if (0 < count)
            {
                this.propertyPatterns = new List<WildcardPattern>(count);
                foreach (var property in this.Property)
                {
                    var pattern = new WildcardPattern(property, WildcardOptions.Compiled | WildcardOptions.CultureInvariant | WildcardOptions.IgnoreCase);
                    this.propertyPatterns.Add(pattern);
                }
            }

            base.BeginProcessing();
        }
开发者ID:heaths,项目名称:psmsi,代码行数:18,代码来源:GetPropertyCommand.cs


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


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


示例20: GetElementsByWildcard

    	// 20140215
        // public static IEnumerable GetElementsByWildcard(this IUiEltCollection collection, string name, string automationId, string className, string txtValue, bool caseSensitive = false)
        public static IEnumerable GetElementsByWildcard(this IUiEltCollection collection, string name, string automationId, string className, string txtValue, bool caseSensitive)
        {
            WildcardOptions options;
            if (caseSensitive) {
                options =
                    WildcardOptions.Compiled;
            } else {
                options =
                    WildcardOptions.IgnoreCase |
                    WildcardOptions.Compiled;
            }
            
            List<IUiElement> list = collection.Cast<IUiElement>().ToList();
            
            var wildcardName = 
                new WildcardPattern((string.IsNullOrEmpty(name) ? "*" : name), options);
            var wildcardAutomationId = 
                new WildcardPattern((string.IsNullOrEmpty(automationId) ? "*" : automationId), options);
            var wildcardClassName = 
                new WildcardPattern((string.IsNullOrEmpty(className) ? "*" : className), options);
            var wildcardValue = 
                new WildcardPattern((string.IsNullOrEmpty(txtValue) ? "*" : txtValue), options);
            
            var queryByBigFour = from collectionItem
                in list
                // 20140312
//                where wildcardName.IsMatch(collectionItem.Current.Name) &&
//                      wildcardAutomationId.IsMatch(collectionItem.Current.AutomationId) &&
//                      wildcardClassName.IsMatch(collectionItem.Current.ClassName) &&
                    where wildcardName.IsMatch(collectionItem.GetCurrent().Name) &&
                wildcardAutomationId.IsMatch(collectionItem.GetCurrent().AutomationId) &&
                wildcardClassName.IsMatch(collectionItem.GetCurrent().ClassName) &&
                      // 20131209
                      // (collectionItem.GetSupportedPatterns().Contains(classic.ValuePattern.Pattern) ?
                      (collectionItem.GetSupportedPatterns().AsQueryable<IBasePattern>().Any<IBasePattern>(p => p is IValuePattern) ?
                      // 20131208
                      // wildcardValue.IsMatch((collectionItem.GetCurrentPattern(classic.ValuePattern.Pattern) as IValuePattern).Current.Value) :
                      // wildcardValue.IsMatch((collectionItem.GetCurrentPattern<IValuePattern, ValuePattern>(classic.ValuePattern.Pattern) as IValuePattern).Current.Value) :
                      wildcardValue.IsMatch(collectionItem.GetCurrentPattern<IValuePattern>(classic.ValuePattern.Pattern).Current.Value) :
                      // check whether the -Value parameter has or hasn't value
                      ("*" == txtValue ? true : false))
                select collectionItem;
            
            // disposal
            list = null;
            
            return queryByBigFour;
        }
开发者ID:universsky,项目名称:STUPS,代码行数:50,代码来源:ExtensionMethodsCollection.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Host.BufferCell类代码示例发布时间:2022-05-26
下一篇:
C# Automation.SessionState类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap