BadScript 2
Loading...
Searching...
No Matches
ArgumentsExtensions.cs
Go to the documentation of this file.
1// Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information.
2
3using System;
4using System.Collections.Generic;
5using System.Linq;
6
7using CSharpx;
8
10{
11 internal static class ArgumentsExtensions
12 {
13 public static IEnumerable<Error> Preprocess(this IEnumerable<string> arguments,
14 IEnumerable<
15 Func<IEnumerable<string>, IEnumerable<Error>>
16 > preprocessorLookup)
17 {
18 return preprocessorLookup.TryHead()
19 .MapValueOrDefault(func =>
20 {
21 IEnumerable<Error> errors = func(arguments);
22
23 return errors.Any()
24 ? errors
25 : arguments.Preprocess(preprocessorLookup
26 .TailNoFail()
27 );
28 },
29 Enumerable.Empty<Error>()
30 );
31 }
32 }
33}
static IEnumerable< Error > Preprocess(this IEnumerable< string > arguments, IEnumerable< Func< IEnumerable< string >, IEnumerable< Error > > > preprocessorLookup)
Base type of all errors.
Definition Error.cs:110