예제 #1
0
 public static Command Then(this Command first, Command next)
 {
     return(Command.Create(first.Action.CombineLatest(next.Action, (o1, o2) =>
     {
         return Optional.Combine(o1, o2, (a1, a2) => a1 + a2);
     })));
 }
예제 #2
0
        static Parsed <Thickness <Points> > TryParseThickness(string str)
        {
            var parts = str.Split(",");

            switch (parts.Length)
            {
            case 1:
                return(parts[0].TryParsePoints()
                       .Select(all => new Thickness <Points>(all)));

            case 2:
                return(Parsed.Create(
                           stringValue: str,
                           value: Optional.Combine(
                               parts[0].TryParsePoints().Value,
                               parts[1].TryParsePoints().Value,
                               (h, v) => new Thickness <Points>(h, v))));

            case 4:
                return(Parsed.Create(
                           stringValue: str,
                           value: Optional.Combine(
                               parts[0].TryParsePoints().Value,
                               parts[1].TryParsePoints().Value,
                               parts[2].TryParsePoints().Value,
                               parts[3].TryParsePoints().Value,
                               (l, t, r, b) => new Thickness <Points>(l, t, r, b))));

            default:
                return(Parsed.Failure <Thickness <Points> >(str));
            }
        }