コード例 #1
0
ファイル: NotNullExtensions.cs プロジェクト: vladris/Maki.NET
 /// <summary>
 /// Binds the given function to the NotNull.
 /// </summary>
 /// <typeparam name="T">NotNull type.</typeparam>
 /// <typeparam name="U">Function return NotNull type.</typeparam>
 /// <param name="notNull">This instance.</param>
 /// <param name="func">Function to bind.</param>
 /// <returns>NotNull containing the result of the function.</returns>
 public static NotNull <U> Bind <T, U>(this NotNull <T> notNull, Func <T, NotNull <U> > func)
 => func(notNull);
コード例 #2
0
ファイル: NotNullExtensions.cs プロジェクト: vladris/Maki.NET
 /// <summary>
 /// Mapsthe given function to the NotNull.
 /// </summary>
 /// <typeparam name="T">NotNull type.</typeparam>
 /// <typeparam name="U">Function return type</typeparam>
 /// <param name="notNull">This instance.</param>
 /// <param name="func">Function to map.</param>
 /// <returns>NotNull containing the result of the function.</returns>
 /// <exception cref="ArgumentNullException">Thrown if the function returns null.</exception>
 public static NotNull <U> Map <T, U>(this NotNull <T> notNull, Func <T, U> func)
 => NotNull.Make(func(notNull));
コード例 #3
0
ファイル: NotNull.cs プロジェクト: vladris/Maki.NET
 /// <summary>
 /// Creates an Optional from the given object which is either Nothing if the
 /// object is null or NotNull if the object is not null.
 /// </summary>
 /// <typeparam name="T">Item type.</typeparam>
 /// <param name="item">Object to store.</param>
 /// <returns>NotNull if object is not null, Nothing otherwise.</returns>
 public static Optional <NotNull <T> > MakeOptional <T>(T item) => NotNull <T> .MakeOptional(item);