本文整理汇总了C#中System.Collections.Generic.System.Collections.Generic.List.Where方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.Generic.List.Where方法的具体用法?C# System.Collections.Generic.List.Where怎么用?C# System.Collections.Generic.List.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Generic.System.Collections.Generic.List
的用法示例。
在下文中一共展示了System.Collections.Generic.List.Where方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReturnOnlyRightElements
// 20130513
//internal ArrayList returnOnlyRightElements(
internal static ArrayList ReturnOnlyRightElements(
//AutomationElementCollection results,
// 20130513
HasTimeoutCmdletBase cmdlet,
IEnumerable results,
//System.Collections.Generic.IEnumerable<AutomationElement> results,
string name,
string automationId,
string className,
string textValue,
string[] controlType,
bool caseSensitive)
{
ArrayList resultCollection = new ArrayList();
WildcardOptions options;
if (caseSensitive) {
options =
WildcardOptions.Compiled;
} else {
options =
WildcardOptions.IgnoreCase |
WildcardOptions.Compiled;
}
if (null == name || string.Empty == name || 0 == name.Length) { name = "*"; }
if (null == automationId || string.Empty == automationId || 0 == automationId.Length) { automationId = "*"; }
if (null == className || string.Empty == className || 0 == className.Length) { className = "*"; }
if (null == textValue || string.Empty == textValue || 0 == textValue.Length) { textValue = "*"; }
//Console.WriteLine("name = " + name);
//Console.WriteLine("auId = " + automationId);
//Console.WriteLine("class = " + className);
//Console.WriteLine("value = " + textValue);
WildcardPattern wildcardName =
new WildcardPattern(name, options);
WildcardPattern wildcardAutomationId =
new WildcardPattern(automationId, options);
WildcardPattern wildcardClass =
new WildcardPattern(className, options);
WildcardPattern wildcardValue =
new WildcardPattern(textValue, options);
// 20130513
//this.WriteVerbose(this, "inside the returnOnlyRightElements method 20");
cmdlet.WriteVerbose(cmdlet, "inside the returnOnlyRightElements method 20");
System.Collections.Generic.List<AutomationElement> list =
new System.Collections.Generic.List<AutomationElement>();
// 20130513
foreach (AutomationElement elt in results) {
list.Add(elt);
}
//list.AddRange(results);
//list.AddRange(results.AsQueryable());
try {
var query = list
// .Where<AutomationElement>(item => wildcardName.IsMatch(item.Current.Name))
// .Where<AutomationElement>(item => wildcardAutomationId.IsMatch(item.Current.AutomationId))
// .Where<AutomationElement>(item => wildcardClass.IsMatch(item.Current.ClassName))
// .Where<AutomationElement>(item =>
// item.GetSupportedPatterns().Contains(ValuePattern.Pattern) ?
// //(("*" != textValue) ? wildcardValue.IsMatch((item.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern).Current.Value) : false) :
// (("*" != textValue) ? (positiveMatch(item, wildcardValue, textValue)) : (negativeMatch(textValue))) :
// true
// )
.Where<AutomationElement>(
item => (wildcardName.IsMatch(item.Current.Name) &&
wildcardAutomationId.IsMatch(item.Current.AutomationId) &&
wildcardClass.IsMatch(item.Current.ClassName) &&
// check whether a control has or hasn't ValuePattern
(item.GetSupportedPatterns().Contains(ValuePattern.Pattern) ?
// 20130513
//testRealValueAndValueParameter(item, name, automationId, className, textValue, wildcardValue) :
cmdlet.testRealValueAndValueParameter(item, name, automationId, className, textValue, wildcardValue) :
// check whether the -Value parameter has or hasn't value
("*" == textValue ? true : false)
)
)
)
.ToArray<AutomationElement>();
// 20130513
//this.WriteVerbose(
// this,
cmdlet.WriteVerbose(
cmdlet,
"There are " +
query.Count().ToString() +
" elements");
resultCollection.AddRange(query);
// 20130513
//.........这里部分代码省略.........