private static void AssertMapLeft(IEither <string, int> either)
        {
            var mapResult = either.Map(v => "1337", v => 1337);

            AssertIsValidLeftEither(mapResult, "1337");
        }
Пример #2
0
 /// <summary>
 /// Maps the left value to a new type.
 /// </summary>
 /// <typeparam name="TLeft">The type of the left.</typeparam>
 /// <typeparam name="TRight">The type of the right.</typeparam>
 /// <typeparam name="TLeftResult">The type of the left result.</typeparam>
 /// <param name="source">The source.</param>
 /// <param name="selector">The selector.</param>
 /// <returns></returns>
 public static Either <TLeftResult, TRight> MapLeft <TLeft, TRight, TLeftResult>(this IEither <TLeft, TRight> source, Func <TLeft, TLeftResult> selector)
 {
     return(source.Map(selector, r => r));
 }
Пример #3
0
 /// <summary>
 /// Maps the right value to a new type.
 /// </summary>
 /// <typeparam name="TLeft">The type of the left.</typeparam>
 /// <typeparam name="TRight">The type of the right.</typeparam>
 /// <typeparam name="TRightResult">The type of the right result.</typeparam>
 /// <param name="source">The source.</param>
 /// <param name="selector">The selector.</param>
 /// <returns></returns>
 public static Either <TLeft, TRightResult> MapRight <TLeft, TRight, TRightResult>(this IEither <TLeft, TRight> source, Func <TRight, TRightResult> selector)
 {
     return(source.Map(l => l, selector));
 }
        private static void AssertMapRight(IEither <int, string> either)
        {
            var mapResult = either.Map(v => 1337, v => "1337");

            AssertIsValidRightEither(mapResult, "1337");
        }