当前位置: 首页>>代码示例>>C#>>正文


C# IOrderedEnumerable.TakeWhile方法代码示例

本文整理汇总了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;
        }
开发者ID:GereG,项目名称:ResponseTip,代码行数:27,代码来源:ArbiterFinder.cs

示例2: GetIndexOfTab

 private static int GetIndexOfTab(TabInfo objTab, IOrderedEnumerable<TabInfo> tabs)
 {
     return Null.NullInteger + tabs.TakeWhile(tab => tab.TabID != objTab.TabID).Count();
 }
开发者ID:biganth,项目名称:Curt,代码行数:4,代码来源:TabController.cs


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