-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
src/PipelineNet/ChainsOfResponsibility/AsyncResponsibilityChainExtensions.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System; | ||
|
||
namespace PipelineNet.ChainsOfResponsibility | ||
{ | ||
public static class AsyncResponsibilityChainExtensions | ||
{ | ||
/// <summary> | ||
/// Throws an <see cref="InvalidOperationException"/> at the end of the chain as a fallback. | ||
/// A chain can only have one finally function. Calling this method more | ||
/// a second time will just replace the existing finally <see cref="Func{TParameter, TResult}"/>. | ||
/// </summary> | ||
/// <param name="chain">The instace of <see cref="IAsyncResponsibilityChain{TParameter, TReturn}"/>.</param> | ||
/// <returns>The current instance of <see cref="IAsyncResponsibilityChain{TParameter, TReturn}"/>.</returns> | ||
public static IAsyncResponsibilityChain<TParameter, TReturn> FinallyThrow<TParameter, TReturn>( | ||
this IAsyncResponsibilityChain<TParameter, TReturn> chain) | ||
{ | ||
if (chain == null) throw new ArgumentNullException("chain"); | ||
|
||
return chain.Finally(_ => | ||
throw new InvalidOperationException("End of the asynchronous chain of responsibility reached. No middleware matches returned a value.")); | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/PipelineNet/ChainsOfResponsibility/ResponsibilityChainExtensions.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System; | ||
|
||
namespace PipelineNet.ChainsOfResponsibility | ||
{ | ||
public static class ResponsibilityChainExtensions | ||
{ | ||
/// <summary> | ||
/// Throws an <see cref="InvalidOperationException"/> at the end of the chain as a fallback. | ||
/// A chain can only have one finally function. Calling this method more | ||
/// a second time will just replace the existing finally <see cref="Func{TParameter, TResult}"/>. | ||
/// </summary> | ||
/// <param name="chain">The instace of <see cref="IResponsibilityChain{TParameter, TReturn}"/>.</param> | ||
/// <returns>The current instance of <see cref="IResponsibilityChain{TParameter, TReturn}"/>.</returns> | ||
public static IResponsibilityChain<TParameter, TReturn> FinallyThrow<TParameter, TReturn>( | ||
this IResponsibilityChain<TParameter, TReturn> chain) | ||
{ | ||
if (chain == null) throw new ArgumentNullException("chain"); | ||
|
||
return chain.Finally(_ => | ||
throw new InvalidOperationException("End of the chain of responsibility reached. No middleware matches returned a value.")); | ||
} | ||
} | ||
} |