Esempio n. 1
0
        public static Maybe <TypeDescriptor> FindTypeDescriptorAndSibling(
            string name,
            IEnumerable <OptionSpecification> specifications,
            StringComparer comparer)
        {
            var info =
                specifications.SingleOrDefault(a => name.MatchName(a.ShortName, a.LongName, comparer))
                .ToMaybe()
                .Map(
                    first =>
            {
                var descr = TypeDescriptor.Create(first.TargetType, first.Max);
                var next  = specifications
                            .SkipWhile(s => s.Equals(first)).Take(1)
                            .SingleOrDefault(x => x.IsValue()).ToMaybe()
                            .Map(second => TypeDescriptor.Create(second.TargetType, second.Max));
                return(descr.WithNextValue(next));
            });

            return(info);
        }
Esempio n. 2
0
 public static TypeDescriptor WithNextValue(this TypeDescriptor descriptor, Maybe <TypeDescriptor> nextValue)
 {
     return(TypeDescriptor.Create(descriptor.TargetType, descriptor.MaxItems, nextValue.GetValueOrDefault(default(TypeDescriptor))));
 }
Esempio n. 3
0
 public static TypeDescriptor WithNextValue(this TypeDescriptor descriptor, Maybe <TypeDescriptor> nextValue)
 {
     return(TypeDescriptor.Create(descriptor.TargetType, descriptor.MaxItems, nextValue.Return(n => n, null)));
 }