コード例 #1
0
 public static Option <TResult> Select <TSource, TResult>(this Option <TSource> source, Func <TSource, TResult> selector)
 {
     if (selector == null)
     {
         throw new ArgumentNullException("selector");
     }
     return(source.Bind(x => Option <TResult> .Return(selector(x))));
 }
コード例 #2
0
 public static Option <TResult> SelectMany <TSource, TCollection, TResult>(
     this Option <TSource> source,
     Func <TSource, Option <TCollection> > collectionSelector,
     Func <TSource, TCollection, TResult> resultSelector)
 {
     if (collectionSelector == null)
     {
         throw new ArgumentNullException("collectionSelector");
     }
     if (resultSelector == null)
     {
         throw new ArgumentNullException("resultSelector");
     }
     return(source.Bind(s => collectionSelector(s).Select(c => resultSelector(s, c))));
 }