コード例 #1
0
        private static PgnGameFinderService.FindOptions CreateOptions(PgnQueryCommandLineParser parser)
        {
            var opts = new PgnGameFinderService.FindOptions(
                parser.FileSources,
                parser.Event,
                parser.Site,
                parser.Date,
                parser.Round,
                parser.White, parser.Black, parser.Result, parser.CountMode, parser.Debug);

            return(opts);
        }
コード例 #2
0
        public bool MatchGame(PgnGame game, PgnGameFinderService.FindOptions options)
        {
            var stringComparisons = new List <Func <bool> >()
            {
                () => _stringComparer.Compare(game.Event.ToLower(), options.Event.ToLower()),
                () => _stringComparer.Compare(game.Site.ToLower(), options.Site.ToLower()),
                () => _stringComparer.Compare(game.Date.ToString().ToLower(), options.Date.ToLower()),
                () => _stringComparer.Compare(game.White.ToLower(), options.White.ToLower()),
                () => _stringComparer.Compare(game.Round.ToLower(), options.Round.ToLower()),
                () => _stringComparer.Compare(game.Black.ToLower(), options.Black.ToLower()),
            };

            return(stringComparisons.All(c => c()) &&
                   _pgnGameResultComparer.Compare(game.Result, options.Result.ToLower())
                   );
        }
コード例 #3
0
 public static IEnumerable <PgnGame> FindGames(this IEnumerable <PgnGame> games, PgnGameFinderService.FindOptions options)
 {
     return(games.Where(g => new PgnGameMatcher().MatchGame(g, options)));
 }