private static ITry <ShoppingListWithItems, AddFoodstuffsError> Process(ApiResult <AddFoodstuffsToShoppingListResponse> response) =>
 response.Match(
     s => Try.Success <ShoppingListWithItems, AddFoodstuffsError>(ToShoppingList(s)),
     e => Try.Error <ShoppingListWithItems, AddFoodstuffsError>(e.Message.Match(
                                                                    "Item already added.", _ => AddFoodstuffsError.FoodstuffAlreadyAdded
                                                                    )),
     noConn => throw new NotImplementedException()
Пример #2
0
 private static ITry <Unit, SignUpError[]> Success() =>
 Try.Success <Unit, SignUpError[]>(Unit.Value);
Пример #3
0
 private static ITry <Unit, SignUpError[]> Error(IEnumerable <SignUpError> errors) =>
 Try.Error <Unit, SignUpError[]>(errors.ToArray());
Пример #4
0
 private static ITry <IAccount, SignInError> Success(IAccount a) =>
 Try.Success <IAccount, SignInError>(a);
Пример #5
0
 private static ITry <IAccount, SignInError> Error(SignInError e) =>
 Try.Error <IAccount, SignInError>(e);
Пример #6
0
 public static ITry <T, E> ToTry <T, E>(this bool b, Func <Unit, T> ifTrue, Func <Unit, E> ifFalse)
 {
     return(b ? Try.Success <T, E>(ifTrue(Unit.Value)) : Try.Error <T, E>(ifFalse(Unit.Value)));
 }