本文整理汇总了C#中IOrderedEnumerable.TakeWhile方法的典型用法代码示例。如果您正苦于以下问题:C# IOrderedEnumerable.TakeWhile方法的具体用法?C# IOrderedEnumerable.TakeWhile怎么用?C# IOrderedEnumerable.TakeWhile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOrderedEnumerable
的用法示例。
在下文中一共展示了IOrderedEnumerable.TakeWhile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindArbiters
public string[] FindArbiters(int arbiterCount, string[] excludedArbiterIds)
{
if (arbiterCount > dbContext.Users.Count())
{
logger.LogLine("Not enough arbiters available! " + arbiterCount+" wanted. ", Logger.log_types.ERROR_LOG);
throw new responseTip.Exceptions.NotEnoughArbitersAvailable();
}
string[] arbiterIds;
//arbiterIds=dbContext.Users.Where(model => model.GetPercentageOfPuzzlesSuccesfull() > 0.5f).OrderByDescending(model => model.GetPercentageOfPuzzlesSuccesfull()).Select(model => model.Id).Take(task.ArbiterCount).ToArray();
orderedArbiters = dbContext.Users.ToList().OrderByDescending(model => model.GetProbabilityOfBeingPicked());
//TODO check if order is not changed by takewhile
orderedArbitersAvailable = orderedArbiters.TakeWhile(model => model.GetNumOfPuzzlesWaiting() < model.GetNumOfPuzzlesLimit());
if (excludedArbiterIds != null)
{
orderedArbitersAvailable = orderedArbitersAvailable.Where(model => !excludedArbiterIds.ToList().Contains(model.Id));
}
arbiterIds=orderedArbitersAvailable.Select(model => model.Id).Take(arbiterCount).ToArray();
// arbiterIds = dbContext.Users.OrderByDescending(model => model.GetProbabilityOfBeingPicked()).Select(model => model.Id).Take(arbiterCount).ToArray();
if(arbiterIds.Count()<arbiterCount)
{
logger.LogLine("Not enough arbiters available! " + arbiterCount + " wanted. ", Logger.log_types.ERROR_LOG);
throw new responseTip.Exceptions.NotEnoughArbitersAvailable();
}
return arbiterIds;
}
示例2: GetIndexOfTab
private static int GetIndexOfTab(TabInfo objTab, IOrderedEnumerable<TabInfo> tabs)
{
return Null.NullInteger + tabs.TakeWhile(tab => tab.TabID != objTab.TabID).Count();
}