4using System.Collections.Generic;
18 IEnumerable<SpecificationProperty>,
Error>
19 MapValues(IEnumerable<SpecificationProperty> specProps,
20 IEnumerable<string> values,
21 Func<IEnumerable<string>, Type,
bool,
Maybe<object>> converter)
23 IEnumerable<Tuple<SpecificationProperty, Maybe<Error>>> propAndErrors =
26 return Result.Succeed(propAndErrors.Select(pe => pe.Item1),
27 propAndErrors.Select(pe => pe.Item2)
33 private static IEnumerable<Tuple<SpecificationProperty, Maybe<Error>>>
MapValuesImpl(
34 IEnumerable<SpecificationProperty> specProps,
35 IEnumerable<string> values,
36 Func<IEnumerable<string>, Type,
bool,
Maybe<object>> converter)
38 if (specProps.Empty())
45 IEnumerable<string> taken = values.Take(pt.
Specification.CountOfMaxNumberOfValues()
46 .GetValueOrDefault(values.Count())
58 .FirstOrDefault(s => s.Specification.IsValue())
63 values.Skip(taken.Count())
82 .MapValueOrDefault(converted =>
83 Tuple.Create(pt.WithValue(
Maybe.Just(converted)),
Maybe.Nothing<
Error>()),
90 values.Skip(taken.Count()),
103 return Maybe.Just(1);
105 if (specification.
Max.IsJust())
107 return Maybe.Just(specification.
Max.FromJustOrFail());
113 return Maybe.Nothing<
int>();
118 return specification.
Min.IsJust()
Models a CSharpx.Maybe when contains a value.
The Maybe type models an optional value. A value of type Maybe a either contains a value of type a (r...
Specification Specification
static SpecificationProperty Create(Specification specification, PropertyInfo property, Maybe< object > value)
static IEnumerable< Tuple< SpecificationProperty, Maybe< Error > > > MapValuesImpl(IEnumerable< SpecificationProperty > specProps, IEnumerable< string > values, Func< IEnumerable< string >, Type, bool, Maybe< object > > converter)
static Maybe< Error > MakeErrorInCaseOfMinConstraint(this Specification specification)
static Maybe< int > CountOfMaxNumberOfValues(this Specification specification)
static Result< IEnumerable< SpecificationProperty >, Error > MapValues(IEnumerable< SpecificationProperty > specProps, IEnumerable< string > values, Func< IEnumerable< string >, Type, bool, Maybe< object > > converter)
Models name information, used in CommandLine.Error instances.
static readonly NameInfo EmptyName
Represents an empty name information. Used when CommandLine.Error are tied to values,...
Models an error generated when a sequence value lacks elements.
Represents the result of a computation.