Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.0-beta.7
1.1.0-beta.9
1 change: 0 additions & 1 deletion Wrap.sln
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ Global
{772813C5-64F7-4547-A45F-637625BFB70F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{772813C5-64F7-4547-A45F-637625BFB70F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{772813C5-64F7-4547-A45F-637625BFB70F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{772813C5-64F7-4547-A45F-637625BFB70F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
42 changes: 21 additions & 21 deletions src/All/Extensions/Maybe/MaybeExtensions.If.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,23 @@ public static Task<Maybe<TReturn>> IfAsync<T, TReturn>(this Task<Maybe<T>> @this
/// </summary>
/// <typeparam name="T">Ok value type.</typeparam>
/// <param name="this">Maybe object.</param>
/// <param name="fTest">Uses value of <paramref name="this"/> to determin whether to return <paramref name="fTrue"/> or original value.</param>
/// <param name="fTrue">Used if <paramref name="this"/> is <see cref="Ok{T}"/> and <paramref name="fTest"/> returns <see langword="true"/>.</param>
/// <returns>Value generated by <paramref name="fTrue"/> or original value if <paramref name="fTest"/> is false.</returns>
public static Maybe<T> If<T>(this Maybe<T> @this, Func<T, bool> fTest, Func<T, Maybe<T>> fTrue) =>
If(@this, fTest, fTrue, x => x);
/// <param name="fTest">Uses value of <paramref name="this"/> to determin whether to return <paramref name="fThen"/> or original value.</param>
/// <param name="fThen">Used if <paramref name="this"/> is <see cref="Ok{T}"/> and <paramref name="fTest"/> returns <see langword="true"/>.</param>
/// <returns>Value generated by <paramref name="fThen"/> or original value if <paramref name="fTest"/> is false.</returns>
public static Maybe<T> If<T>(this Maybe<T> @this, Func<T, bool> fTest, Func<T, Maybe<T>> fThen) =>
If(@this, fTest, fThen, x => x);

/// <inheritdoc cref="If{T}(Maybe{T}, Func{T, bool}, Func{T, Maybe{T}})"/>
public static Task<Maybe<T>> IfAsync<T>(this Maybe<T> @this, Func<T, bool> fTest, Func<T, Task<Maybe<T>>> fTrue) =>
IfAsync(@this.AsTask(), fTest, fTrue, async x => x);
public static Task<Maybe<T>> IfAsync<T>(this Maybe<T> @this, Func<T, bool> fTest, Func<T, Task<Maybe<T>>> fThen) =>
IfAsync(@this.AsTask(), fTest, fThen, async x => x);

/// <inheritdoc cref="If{T}(Maybe{T}, Func{T, bool}, Func{T, Maybe{T}})"/>
public static Task<Maybe<T>> IfAsync<T>(this Task<Maybe<T>> @this, Func<T, bool> fTest, Func<T, Maybe<T>> fTrue) =>
IfAsync(@this, fTest, async x => fTrue(x), async x => x);
public static Task<Maybe<T>> IfAsync<T>(this Task<Maybe<T>> @this, Func<T, bool> fTest, Func<T, Maybe<T>> fThen) =>
IfAsync(@this, fTest, async x => fThen(x), async x => x);

/// <inheritdoc cref="If{T}(Maybe{T}, Func{T, bool}, Func{T, Maybe{T}})"/>
public static Task<Maybe<T>> IfAsync<T>(this Task<Maybe<T>> @this, Func<T, bool> fTest, Func<T, Task<Maybe<T>>> fTrue) =>
IfAsync(@this, fTest, fTrue, async x => x);
public static Task<Maybe<T>> IfAsync<T>(this Task<Maybe<T>> @this, Func<T, bool> fTest, Func<T, Task<Maybe<T>>> fThen) =>
IfAsync(@this, fTest, fThen, async x => x);

#endregion

Expand All @@ -86,22 +86,22 @@ public static Task<Maybe<T>> IfAsync<T>(this Task<Maybe<T>> @this, Func<T, bool>
/// <typeparam name="T">Ok value type.</typeparam>
/// <param name="this">Maybe object.</param>
/// <param name="fTest">Uses value of <paramref name="this"/> if <paramref name="this"/> is <see cref="Ok{T}"/>.</param>
/// <param name="fFalse">Used if <paramref name="this"/> is <see cref="Ok{T}"/> and <paramref name="fTest"/> returns <see langword="false"/>.</param>
/// <returns>Original value or value generated by<paramref name="fFalse"/>.</returns>
public static Maybe<T> IfNot<T>(this Maybe<T> @this, Func<T, bool> fTest, Func<T, Maybe<T>> fFalse) =>
If(@this, fTest, x => x, fFalse);
/// <param name="fThen">Used if <paramref name="this"/> is <see cref="Ok{T}"/> and <paramref name="fTest"/> returns <see langword="false"/>.</param>
/// <returns>Original value or value generated by<paramref name="fThen"/>.</returns>
public static Maybe<T> IfNot<T>(this Maybe<T> @this, Func<T, bool> fTest, Func<T, Maybe<T>> fThen) =>
If(@this, fTest, x => x, fThen);

/// <inheritdoc cref="IfNot{T}(Maybe{T}, Func{T, bool}, Func{T, Maybe{T}})"/>
public static Task<Maybe<T>> IfNotAsync<T>(this Maybe<T> @this, Func<T, bool> fTest, Func<T, Task<Maybe<T>>> fFalse) =>
IfAsync(@this.AsTask(), fTest, async x => x, fFalse);
public static Task<Maybe<T>> IfNotAsync<T>(this Maybe<T> @this, Func<T, bool> fTest, Func<T, Task<Maybe<T>>> fThen) =>
IfAsync(@this.AsTask(), fTest, async x => x, fThen);

/// <inheritdoc cref="IfNot{T}(Maybe{T}, Func{T, bool}, Func{T, Maybe{T}})"/>
public static Task<Maybe<T>> IfNotAsync<T>(this Task<Maybe<T>> @this, Func<T, bool> fTest, Func<T, Maybe<T>> fFalse) =>
IfAsync(@this, fTest, async x => x, async x => fFalse(x));
public static Task<Maybe<T>> IfNotAsync<T>(this Task<Maybe<T>> @this, Func<T, bool> fTest, Func<T, Maybe<T>> fThen) =>
IfAsync(@this, fTest, async x => x, async x => fThen(x));

/// <inheritdoc cref="IfNot{T}(Maybe{T}, Func{T, bool}, Func{T, Maybe{T}})"/>
public static Task<Maybe<T>> ContinueIfAsync<T>(this Task<Maybe<T>> @this, Func<T, bool> fTest, Func<T, Task<Maybe<T>>> fFalse) =>
IfAsync(@this, fTest, async x => x, fFalse);
public static Task<Maybe<T>> IfNotAsync<T>(this Task<Maybe<T>> @this, Func<T, bool> fTest, Func<T, Task<Maybe<T>>> fThen) =>
IfAsync(@this, fTest, async x => x, fThen);

#endregion
}
42 changes: 21 additions & 21 deletions src/All/Extensions/Result/ResultExtensions.If.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,23 @@ public static Task<Result<TReturn>> IfAsync<T, TReturn>(this Task<Result<T>> @th
/// </summary>
/// <typeparam name="T">Ok value type.</typeparam>
/// <param name="this">Result object.</param>
/// <param name="fTest">Uses value of <paramref name="this"/> to determin whether to return <paramref name="fTrue"/> or original value.</param>
/// <param name="fTrue">Used if <paramref name="this"/> is <see cref="Ok{T}"/> and <paramref name="fTest"/> returns <see langword="true"/>.</param>
/// <returns>Value generated by <paramref name="fTrue"/> or original value if <paramref name="fTest"/> is false.</returns>
public static Result<T> If<T>(this Result<T> @this, Func<T, bool> fTest, Func<T, Result<T>> fTrue) =>
If(@this, fTest, fTrue, x => x);
/// <param name="fTest">Uses value of <paramref name="this"/> to determin whether to return <paramref name="fThen"/> or original value.</param>
/// <param name="fThen">Used if <paramref name="this"/> is <see cref="Ok{T}"/> and <paramref name="fTest"/> returns <see langword="true"/>.</param>
/// <returns>Value generated by <paramref name="fThen"/> or original value if <paramref name="fTest"/> is false.</returns>
public static Result<T> If<T>(this Result<T> @this, Func<T, bool> fTest, Func<T, Result<T>> fThen) =>
If(@this, fTest, fThen, x => x);

/// <inheritdoc cref="If{T}(Result{T}, Func{T, bool}, Func{T, Result{T}})"/>
public static Task<Result<T>> IfAsync<T>(this Result<T> @this, Func<T, bool> fTest, Func<T, Task<Result<T>>> fTrue) =>
IfAsync(@this.AsTask(), fTest, fTrue, async x => x);
public static Task<Result<T>> IfAsync<T>(this Result<T> @this, Func<T, bool> fTest, Func<T, Task<Result<T>>> fThen) =>
IfAsync(@this.AsTask(), fTest, fThen, async x => x);

/// <inheritdoc cref="If{T}(Result{T}, Func{T, bool}, Func{T, Result{T}})"/>
public static Task<Result<T>> IfAsync<T>(this Task<Result<T>> @this, Func<T, bool> fTest, Func<T, Result<T>> fTrue) =>
IfAsync(@this, fTest, async x => fTrue(x), async x => x);
public static Task<Result<T>> IfAsync<T>(this Task<Result<T>> @this, Func<T, bool> fTest, Func<T, Result<T>> fThen) =>
IfAsync(@this, fTest, async x => fThen(x), async x => x);

/// <inheritdoc cref="If{T}(Result{T}, Func{T, bool}, Func{T, Result{T}})"/>
public static Task<Result<T>> IfAsync<T>(this Task<Result<T>> @this, Func<T, bool> fTest, Func<T, Task<Result<T>>> fTrue) =>
IfAsync(@this, fTest, fTrue, async x => x);
public static Task<Result<T>> IfAsync<T>(this Task<Result<T>> @this, Func<T, bool> fTest, Func<T, Task<Result<T>>> fThen) =>
IfAsync(@this, fTest, fThen, async x => x);

#endregion

Expand All @@ -86,22 +86,22 @@ public static Task<Result<T>> IfAsync<T>(this Task<Result<T>> @this, Func<T, boo
/// <typeparam name="T">Ok value type.</typeparam>
/// <param name="this">Result object.</param>
/// <param name="fTest">Uses value of <paramref name="this"/> if <paramref name="this"/> is <see cref="Ok{T}"/>.</param>
/// <param name="fFalse">Used if <paramref name="this"/> is <see cref="Ok{T}"/> and <paramref name="fTest"/> returns <see langword="false"/>.</param>
/// <returns>Original value or value generated by<paramref name="fFalse"/>.</returns>
public static Result<T> IfNot<T>(this Result<T> @this, Func<T, bool> fTest, Func<T, Result<T>> fFalse) =>
If(@this, fTest, x => x, fFalse);
/// <param name="fThen">Used if <paramref name="this"/> is <see cref="Ok{T}"/> and <paramref name="fTest"/> returns <see langword="false"/>.</param>
/// <returns>Original value or value generated by<paramref name="fThen"/>.</returns>
public static Result<T> IfNot<T>(this Result<T> @this, Func<T, bool> fTest, Func<T, Result<T>> fThen) =>
If(@this, fTest, x => x, fThen);

/// <inheritdoc cref="IfNot{T}(Result{T}, Func{T, bool}, Func{T, Result{T}})"/>
public static Task<Result<T>> IfNotAsync<T>(this Result<T> @this, Func<T, bool> fTest, Func<T, Task<Result<T>>> fFalse) =>
IfAsync(@this.AsTask(), fTest, async x => x, fFalse);
public static Task<Result<T>> IfNotAsync<T>(this Result<T> @this, Func<T, bool> fTest, Func<T, Task<Result<T>>> fThen) =>
IfAsync(@this.AsTask(), fTest, async x => x, fThen);

/// <inheritdoc cref="IfNot{T}(Result{T}, Func{T, bool}, Func{T, Result{T}})"/>
public static Task<Result<T>> IfNotAsync<T>(this Task<Result<T>> @this, Func<T, bool> fTest, Func<T, Result<T>> fFalse) =>
IfAsync(@this, fTest, async x => x, async x => fFalse(x));
public static Task<Result<T>> IfNotAsync<T>(this Task<Result<T>> @this, Func<T, bool> fTest, Func<T, Result<T>> fThen) =>
IfAsync(@this, fTest, async x => x, async x => fThen(x));

/// <inheritdoc cref="IfNot{T}(Result{T}, Func{T, bool}, Func{T, Result{T}})"/>
public static Task<Result<T>> ContinueIfAsync<T>(this Task<Result<T>> @this, Func<T, bool> fTest, Func<T, Task<Result<T>>> fFalse) =>
IfAsync(@this, fTest, async x => x, fFalse);
public static Task<Result<T>> IfNotAsync<T>(this Task<Result<T>> @this, Func<T, bool> fTest, Func<T, Task<Result<T>>> fThen) =>
IfAsync(@this, fTest, async x => x, fThen);

#endregion
}