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


C# IEnumerable.TakeWhile方法代码示例

本文整理汇总了C#中IEnumerable.TakeWhile方法的典型用法代码示例。如果您正苦于以下问题:C# IEnumerable.TakeWhile方法的具体用法?C# IEnumerable.TakeWhile怎么用?C# IEnumerable.TakeWhile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IEnumerable的用法示例。


在下文中一共展示了IEnumerable.TakeWhile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetIncidentsReverse

 static List<DataSample> GetIncidentsReverse(IEnumerable<DataSample> samples, int sessionNumber, int maxTotalIncidents)
 {
     return IncidentsSupport.FindIncidents(
         samples.TakeWhile(data => data.Telemetry.SessionNum == sessionNumber && data.Telemetry.RaceLaps > 0),
         d => iRacing.Replay.MoveToPrevIncident(),
         maxTotalIncidents);
 }
开发者ID:RobRobertsCE,项目名称:iRacingSolution,代码行数:7,代码来源:Incidents.cs

示例2: Arguments

 public Arguments(IEnumerable<string> args, IEnumerable<Option> options)
 {
     if (args == null)
         throw new ArgumentNullException("args");
     Switches = new Dictionary<string, bool?>(StringComparer.CurrentCultureIgnoreCase);
     Variables = new Dictionary<string, string>(StringComparer.CurrentCultureIgnoreCase);
     Parameters = args;
     Options = options;
     foreach (var argument in Parameters.TakeWhile(item => item.StartsWith("-") &&
                                                   item.Length > 1)) {
         var name = argument.TrimStart('-');
         int colon = name.IndexOf(':');
         if (colon > 0) {
             var value = name.Substring(colon + 1);
             name = name.Substring(0, colon - 1);
             name = GetOptionName(name);
             Variables[name] = value;
         } else {
             name = GetOptionName(name);
             bool? value = null;
             if (name.EndsWith("+")) {
                 name = argument.Substring(0, name.Length - 1);
                 value = true;
             } else if (name.EndsWith("-")) {
                 name = name.Substring(0, name.Length - 1);
                 value = false;
             }
             Switches[name] = value;
         }
     }
     Parameters = Parameters.Skip(Switches.Count + Variables.Count);
 }
开发者ID:prantlf,项目名称:dirsync,代码行数:32,代码来源:Arguments.cs

示例3: GetIncidentsForward

 static List<DataSample> GetIncidentsForward(IEnumerable<DataSample> samples, int maxTotalIncidents)
 {
     return IncidentsSupport.FindIncidents(
         samples.TakeWhile(data => data.Telemetry.SessionState != SessionState.CoolDown),
         d => iRacing.Replay.MoveToNextIncident(),
         maxTotalIncidents);
 }
开发者ID:RobRobertsCE,项目名称:iRacingSolution,代码行数:7,代码来源:Incidents.cs

示例4: Parse

        public static PageMeta Parse(IEnumerable<string> lines)
        {
            var meta = new PageMeta();
            foreach (var line in lines.TakeWhile(line => line.StartsWith(MD_META_PREFIX)))
            {
                var metaType = new string(line.Skip(MD_META_PREFIX.Length).TakeWhile(c => c != ' ').ToArray());
                var content = new string(line.Skip(metaType.Length + 3).ToArray());

                switch (metaType)
                {
                    case "title":
                        meta.Title = content;
                        break;
                    case "date":
                        DateTimeOffset articleDate;
                        if (DateTimeOffset.TryParse(content, out articleDate))
                        {
                            meta.Date = articleDate;
                        }
                        break;
                }
            }

            return meta;
        }
开发者ID:rikkit,项目名称:homepage,代码行数:25,代码来源:PageMeta.cs

示例5: HandleAction

        private ParserContext HandleAction(IEnumerable<string> parts)
        {
            var actionParts = parts.TakeWhile(s => !s.StartsWith("@")).TakeWhile(s => !s.Equals("@@"));

            CurrentParserContext.ContextContent = String.Join(" ", actionParts);

            return CurrentParserContext;
        }
开发者ID:foliveira,项目名称:life-logging,代码行数:8,代码来源:ParserEngine.cs

示例6: Preprocess

 public Result<IEnumerable<Token>, Error> Preprocess(
     IEnumerable<string> arguments,
     Func<IEnumerable<string>, Result<IEnumerable<Token>, Error>> tokenizer)
 {
     if (arguments.Any(arg => arg.EqualsOrdinal("--")))
     {
         var tokenizerResult = tokenizer(arguments.TakeWhile(arg => !arg.EqualsOrdinal("--")));
         var values = arguments.SkipWhile(arg => !arg.EqualsOrdinal("--")).Skip(1).Select(Token.Value);
         return tokenizerResult.Map(tokens => tokens.Concat(values));
     }
     if (arguments.Any(arg => arg.EqualsOrdinal("//")))
     {
         var tokenizerResult = tokenizer(arguments.TakeWhile(arg => !arg.EqualsOrdinal("--")));
         var values = arguments.SkipWhile(arg => !arg.EqualsOrdinal("//")).Skip(1).Select(Token.Value);
         return tokenizerResult.Map(tokens => tokens.Concat(values));
     }
     return tokenizer(arguments);
 }
开发者ID:Ehryk,项目名称:commandline,代码行数:18,代码来源:TokenizerHybrid.cs

示例7: GetIncidentsForward

        static List<DataSample> GetIncidentsForward(IEnumerable<DataSample> samples, int sampleScanSettle, int maxTotalIncidents)
        {
            TraceDebug.WriteLine("Scanning for incidents forwards from start");

            return IncidentsSupport.FindIncidents(
                samples.TakeWhile(data => data.Telemetry.SessionState != SessionState.CoolDown),
                sampleScanSettle,
                maxTotalIncidents);
        }
开发者ID:jrc60752,项目名称:iRacingSDK.Net,代码行数:9,代码来源:Incidents.cs

示例8: PreprocessDashDash

 public static StatePair<IEnumerable<Token>> PreprocessDashDash(
     IEnumerable<string> arguments,
     Func<IEnumerable<string>, StatePair<IEnumerable<Token>>> tokenizer)
 {
     if (arguments.Any(arg => arg.EqualsOrdinal("--")))
     {
         var tokenizerResult = tokenizer(arguments.TakeWhile(arg => !arg.EqualsOrdinal("--")));
         var values = arguments.SkipWhile(arg => !arg.EqualsOrdinal("--")).Skip(1).Select(Token.Value);
         return tokenizerResult.MapValue(tokens => tokens.Concat(values));
     }
     return tokenizer(arguments);
 }
开发者ID:forki,项目名称:commandline,代码行数:12,代码来源:Tokenizer.cs

示例9: Produce

 public static DigitSequence Produce(IEnumerable<Symbol> symbols,
 	out IEnumerable<Symbol> symbolsToProcess)
 {
     // digit-sequence = 1*decimal-digit
     IEnumerable<Symbol> digits = symbols.TakeWhile(s =>
         s is DecimalDigit);
     if (digits.Any())
     {
         symbolsToProcess = symbols.Skip(digits.Count());
         return new DigitSequence(digits);
     }
     symbolsToProcess = null;
     return null;
 }
开发者ID:cheshire137,项目名称:SnazzyCalculator,代码行数:14,代码来源:DigitSequence.cs

示例10: Produce

 public static Expression Produce(IEnumerable<Symbol> symbols)
 {
     // expression = *whitespace nospace-expression *whitespace
     int numSpaceBefore = symbols.TakeWhile(s => s is WhiteSpace).Count();
     int numSpaceAfter = symbols.Reverse()
         .TakeWhile(s => s is WhiteSpace).Count();
     IEnumerable<Symbol> noSpaceSymbolList = symbols
         .Skip(numSpaceBefore)
         .SkipLast(numSpaceAfter)
         .ToList();
     NoSpaceExpression n = NoSpaceExpression.Produce(noSpaceSymbolList);
     if (null == n)
     {
         return null;
     }
     return new Expression(WhiteSpace.CreateWhiteSpace(numSpaceBefore),
                           n, WhiteSpace.CreateWhiteSpace(numSpaceAfter));
 }
开发者ID:cheshire137,项目名称:SnazzyCalculator,代码行数:18,代码来源:Expression.cs

示例11: ProcessCommits

        public static void ProcessCommits(this IBot bot, string repositoryName ,string lastCommit, IEnumerable<dynamic> commits)
        {
            // find new commits since
            var groupedCommits = commits.TakeWhile(c => c.commit.tree.sha != lastCommit).GroupBy(c => c.committer.login);

            // create string to send as message
            var sb = new StringBuilder();
            sb.AppendFormat("github: there are new commits in the {0} repository\r\n", repositoryName);
            foreach (var committer in groupedCommits)
            {
                sb.AppendFormat("{0} had {1} commits\r\n", committer.Key, committer.Count());
            }

            // split into rows and send to rooms
            var rows = sb.ToString().Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            foreach (var row in rows)
                bot.SayToAllRooms(row);
        }
开发者ID:shiftkey,项目名称:jibbr,代码行数:18,代码来源:BotCommitExtensions.cs

示例12: Produce

        public static Expression Produce(IEnumerable<Symbol> symbols)
        {
            // expression = *whitespace nospace-expression *whitespace

            var whiteSpaceBefore = symbols.TakeWhile(s => s is WhiteSpace)
                                          .Count();
            var whiteSpaceAfter = symbols.Reverse()
                                         .TakeWhile(s => s is WhiteSpace)
                                         .Count();
            var noSpaceSymbolList = symbols.Skip(whiteSpaceBefore)
                                           .SkipLast(whiteSpaceAfter)
                                           .ToList();  // ToList is vital here!
            var nospaceExpression = NospaceExpression.Produce(noSpaceSymbolList);
            return nospaceExpression == null
                       ? null
                       : new Expression(
                             Enumerable.Repeat(new WhiteSpace(), whiteSpaceBefore),
                             nospaceExpression,
                             Enumerable.Repeat(new WhiteSpace(), whiteSpaceAfter));
        }
开发者ID:paulroho,项目名称:Parser,代码行数:20,代码来源:Expression.cs

示例13: MoveFirst

        /// <summary>
        /// See if we can move the statement to the front of the line.
        /// </summary>
        /// <param name="statementToMove"></param>
        /// <param name="statements"></param>
        /// <returns></returns>
        private static bool MoveFirst(IStatement statementToMove, IEnumerable<IStatement> statements)
        {
            // Walk backwards through previous statements
            var prevStatements = statements.TakeWhile(s => s != statementToMove).Reverse();

            // See if we can move.
            foreach (var s in prevStatements)
            {
                if (!StatementCommutes(s, statementToMove))
                {
                    return false;
                }
            }

            // If we can commute everywhere, then we are done!
            return true;
        }
开发者ID:gordonwatts,项目名称:LINQtoROOT,代码行数:23,代码来源:CommonStatementLifter.cs

示例14: CreateSegment

 private static IEnumerable<string> CreateSegment(IEnumerable<string> current, IEnumerable<string> previous)
 {
     return current.TakeWhile((step, index) => step == previous.ElementAtOrDefault(index)).ToArray();
 }
开发者ID:jugglingnutcase,项目名称:EmbeddedStaticIssue,代码行数:4,代码来源:EmbeddedViewLocationProvider.cs

示例15: PopulateWithRatings

        public static void PopulateWithRatings(this List<IUser> users, IEnumerable<IRating> ratings, bool combineDuplicateArtists = false)
        {
            foreach (var rating in ratings.TakeWhile(rating => rating.UserIndex < users.Count))
                users[rating.UserIndex].Ratings.Add(rating);

            if (combineDuplicateArtists)
                users.CombineDuplicateArtists();
        }
开发者ID:gligoran,项目名称:RecommendationSystem,代码行数:8,代码来源:RatingProvider.cs


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