Last active
September 15, 2017 07:43
-
-
Save nojaf/a3eb9f1d1cffa395e700c449c14b88a3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static Option<TException> WithoutValue<TValue, TException>(this Option<TValue, TException> option) | |
| { | |
| return option.Match(_ => Option.None<TException>(), exception => exception.Some()); | |
| } | |
| public static IEnumerable<TValue> Values<TValue, TException>(this IEnumerable<Option<TValue, TException>> source) | |
| { | |
| if (source == null) throw new ArgumentNullException(nameof(source)); | |
| return source.SelectMany(option => option.ToEnumerable()); | |
| } | |
| public static IEnumerable<TException> Exceptions<TValue, TException>(this IEnumerable<Option<TValue, TException>> source) | |
| { | |
| if (source == null) throw new ArgumentNullException(nameof(source)); | |
| return source.SelectMany(option => option.WithoutValue().ToEnumerable()); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment