本文整理汇总了C#中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.List
的用法示例。
在下文中一共展示了System.Collections.Generic.List.Where方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: returnOnlyRightElements
internal ArrayList returnOnlyRightElements(
//AutomationElementCollection results,
IEnumerable 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 = "*"; }
WildcardPattern wildcardName =
new WildcardPattern(name, options);
WildcardPattern wildcardAutomationId =
new WildcardPattern(automationId, options);
WildcardPattern wildcardClass =
new WildcardPattern(className, options);
WildcardPattern wildcardValue =
new WildcardPattern(textValue, options);
this.WriteVerbose(this, "inside the returnOnlyRightElements method 20");
System.Collections.Generic.List<AutomationElement> list =
new System.Collections.Generic.List<AutomationElement>();
foreach (AutomationElement elt in results) {
list.Add(elt);
}
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) ?
testRealValueAndValueParameter(item, name, automationId, className, textValue, wildcardValue) :
// check whether the -Value parameter has or hasn't value
("*" == textValue ? true : false)
)
)
)
.ToArray<AutomationElement>();
this.WriteVerbose(
this,
"There are " +
query.Count().ToString() +
" elements");
resultCollection.AddRange(query);
this.WriteVerbose(
this,
"There are " +
resultCollection.Count.ToString() +
" elements");
}
catch {
}
return resultCollection;
}
示例2: ExportDatabase
//.........这里部分代码省略.........
fileString += FormatLine(" {");
fileString += FormatLine(" float [] temp = new float[splitpath.Length];");
fileString += FormatLine(" if(float.TryParse(splitpath[j], out temp[j]))");
fileString += FormatLine(" {");
fileString += FormatLine(" results[j] = temp[j];");
fileString += FormatLine(" }");
fileString += FormatLine(" else ");
fileString += FormatLine(" {");
fileString += FormatLine(" Debug.LogError(\"Error parsing \" + "
+ "_" + varNames[i]
+
" + \" Component: \" + splitpath[i] + \" parameter \" + i + \" of variable "
+ colNames[i] + "\");");
fileString += FormatLine(" continue;");
fileString += FormatLine(" }");
fileString += FormatLine(" }");
fileString +=
FormatLine(" " + varNames[i] + ".Add( new " + StripArray(types[i]) +
"(results[0], results[1], results[2], results[3] ));");
fileString += FormatLine(" }");
fileString += FormatLine(" }");
fileString += FormatLine(" }");
}
else
{
fileString += FormatLine(" " + varNames[i] + " = _" + varNames[i] + ";");
}
}
fileString += FormatLine(" }");
fileString += FormatLine(System.String.Empty);
{
var colCount = colNames.Where((in_t, in_i) => !GfuStrCmp(in_t, "VOID") && !GfuStrCmp(types[in_i], "Ignore")).Count();
fileString += FormatLine(" public int Length { get { return " + colCount + "; } }");
}
fileString += FormatLine(System.String.Empty);
// allow indexing by []
fileString += FormatLine(" public string this[int i]");
fileString += FormatLine(" {");
fileString += FormatLine(" get");
fileString += FormatLine(" {");
fileString += FormatLine(" return GetStringDataByIndex(i);");
fileString += FormatLine(" }");
fileString += FormatLine(" }");
fileString += FormatLine(System.String.Empty);
// get string data by index lets the user use an int field rather than the name to retrieve the data
fileString += FormatLine(" public string GetStringDataByIndex( int index )");
fileString += FormatLine(" {");
fileString += FormatLine(" string ret = System.String.Empty;");
fileString += FormatLine(" switch( index )");
fileString += FormatLine(" {");
{
var colNum = 0;
for (var i = 0; i < colNames.Count; i++)
{
if (GfuStrCmp(types[i], "Ignore"))
continue;
if (GfuStrCmp(colNames[i], "VOID"))
continue;
fileString += FormatLine(" case " + colNum++ + ":");
fileString += FormatLine(" ret = " + varNames[i] + ".ToString();");
fileString += FormatLine(" break;");
}
示例3: Tick
public static void Tick(EventArgs args)
{
if (!Game.IsInGame || Game.IsPaused || Game.IsWatchingGame)
return;
me = ObjectMgr.LocalHero;
if (me == null)
return;
if (me.ClassID != ClassID.CDOTA_Unit_Hero_EarthSpirit)
return;
//SKILLS
if (Qskill == null)
Qskill = me.Spellbook.SpellQ;
if (Wskill == null)
Wskill = me.Spellbook.SpellW;
if (Eskill == null)
Eskill = me.Spellbook.SpellE;
if (DRemnant == null)
DRemnant = me.Spellbook.SpellD;
if (Rskill == null)
Rskill = me.Spellbook.SpellR;
if (Fskill == null)
Fskill = me.Spellbook.SpellF;
// UNIT VARIABLES
stone_for_combo = ObjectMgr.GetEntities<Unit>().Where(x => x.ClassID == ClassID.CDOTA_Unit_Earth_Spirit_Stone && me.Distance2D(x.NetworkPosition) < 200).FirstOrDefault();
stone = ObjectMgr.GetEntities<Unit>().Where(x => x.ClassID == ClassID.CDOTA_Unit_Earth_Spirit_Stone && x.NetworkPosition.Distance2D(me.NetworkPosition) <= 1300).ToList();
if (boulder_slow == null || stage_combo4 == 0)
boulder_slow = ObjectMgr.GetEntities<Hero>().Where(x => x.Team != me.Team && x.IsVisible && !x.IsIllusion && x.NetworkPosition.Distance2D(me.NetworkPosition) < 200 && x.Modifiers.Any(y => y.Name == "modifier_earth_spirit_rolling_boulder_slow")).FirstOrDefault();
if (stage == 2 && stunned == null)
stunned = ObjectMgr.GetEntities<Hero>().Where(x => x.Modifiers.Any(y => y.Name == "modifier_stunned") && !x.IsIllusion && x.Team != me.Team && x.IsVisible).FirstOrDefault();
//KEYS TOGGLE
if ((Game.IsKeyDown(_hotkeys_config.Item("hotkeycombo1").GetValue<KeyBind>().Key)) && !Game.IsChatOpen && stunned == null)
key_active = true;
if ((Game.IsKeyDown(_hotkeys_config.Item("hotkeycombo3").GetValue<KeyBind>().Key)) && !Game.IsChatOpen)
key_active_2 = true;
if ((Game.IsKeyDown(_hotkeys_config.Item("hotkeycombo5").GetValue<KeyBind>().Key)) && !Game.IsChatOpen)
key_active_4 = true;
if (key_active == false)
{ stage = 0; key_active = false; stunned = null; }
if (me.CanCast() && !me.IsChanneling() && key_active)
{
Mouse_Position = Game.MousePosition;
if ((!Eskill.CanBeCasted() && !Qskill.CanBeCasted() && !Wskill.CanBeCasted() && (!DRemnant.CanBeCasted() && stone_for_combo == null) || ((!DRemnant.CanBeCasted() && stone_for_combo == null))) || (Game.IsKeyDown(_hotkeys_config.Item("hotkeycombo2").GetValue<KeyBind>().Key)))
{
if (auto_atack_after_spell)
{
Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 1");
auto_atack_after_spell = false;
}
if (auto_atack)
{
Game.ExecuteCommand("dota_player_units_auto_attack 1");
auto_atack = false;
}
key_active = false;
stage = 0;
stunned = null;
}
if (stage == 0 && Utils.SleepCheck("auto_atack_change"))
{
if (Game.GetConsoleVar("dota_player_units_auto_attack_after_spell").GetInt() == 1)
{
Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
auto_atack_after_spell = true;
}
else
auto_atack_after_spell = false;
if (Game.GetConsoleVar("dota_player_units_auto_attack").GetInt() == 1)
{
Game.ExecuteCommand("dota_player_units_auto_attack 0");
auto_atack = true;
}
else
auto_atack = false;
stage = 1;
Utils.Sleep(Game.Ping, "auto_atack_change");
}
else if (stage == 1 && Utils.SleepCheck("Qskill") && Utils.SleepCheck("auto_atack_change"))
{
if (DRemnant.CanBeCasted() && Utils.SleepCheck("DRemnant") && stone_for_combo == null && (Qskill.CanBeCasted() && Wskill.CanBeCasted() && Eskill.CanBeCasted()))
{
DRemnant.UseAbility(me.NetworkPosition);
Utils.Sleep(500 - (int)Game.Ping, "DRemnant");
}
if (Qskill.CanBeCasted())
{
Qskill.UseAbility((Mouse_Position - me.NetworkPosition) * 200 / Mouse_Position.Distance2D(me) + me.NetworkPosition);
Utils.Sleep((int)Game.Ping + 50, "Qskill");
}
else
stage = 2;
//.........这里部分代码省略.........