本文整理汇总了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[] {};
}
}
}
示例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);
}
}
示例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));
}
}
}
}
示例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();
}
示例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;
}
示例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();
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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)));
}
}
示例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));
}
}