Skip to content

Commit

Permalink
Merge branch 'master' into finally2
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusz96 authored Nov 5, 2024
2 parents 91a0213 + bfdf35c commit 0d592aa
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ You can even define a fallback that will be executed after your entire chain:
var exceptionHandlersChain = new ResponsibilityChain<Exception, bool>(new ActivatorMiddlewareResolver())
.Chain<OutOfMemoryExceptionHandler>() // The order of middleware being chained matters
.Chain<ArgumentExceptionHandler>()
.Finally<DoSomething>();
.Finally<ExceptionHandlerFallback>();

public class DoSomething : IFinally<Exception, bool>
public class ExceptionHandlerFallback : IFinally<Exception, bool>
{
public bool Finally(Exception parameter)
{
Expand Down Expand Up @@ -202,9 +202,9 @@ If you want to, you can use the asynchronous version, using asynchronous middlew
var exceptionHandlersChain = new AsyncResponsibilityChain<Exception, bool>(new ActivatorMiddlewareResolver())
.Chain<OutOfMemoryAsyncExceptionHandler>() // The order of middleware being chained matters
.Chain<ArgumentAsyncExceptionHandler>()
.Finally<ExceptionHandlerFallback>();
.Finally<ExceptionHandlerAsyncFallback>();

public class ExceptionHandlerFallback : IAsyncFinally<Exception, bool>
public class ExceptionHandlerAsyncFallback : IAsyncFinally<Exception, bool>
{
public Task<bool> Finally(Exception parameter)
{
Expand Down Expand Up @@ -374,9 +374,9 @@ With:
var exceptionHandlersChain = new ResponsibilityChain<Exception, bool>(new ActivatorMiddlewareResolver())
.Chain<OutOfMemoryExceptionHandler>()
.Chain<ArgumentExceptionHandler>()
.Finally<DoSomething>();
.Finally<ExceptionHandlerFallback>();

public class DoSomething : IFinally<Exception, bool>
public class ExceptionHandlerFallback : IFinally<Exception, bool>
{
public bool Finally(Exception parameter)
{
Expand Down
6 changes: 3 additions & 3 deletions src/PipelineNet/AsyncBaseMiddlewareFlow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ internal static async Task DisposeMiddlewareAsync(MiddlewareResolverResult middl
await asyncDisposable.DisposeAsync().ConfigureAwait(false);
}
else
#else
var completedTask = Task.FromResult(0);
await completedTask.ConfigureAwait(false);
#endif
if (middleware is IDisposable disposable)
{
disposable.Dispose();
}

var completedTask = Task.FromResult(0);
await completedTask.ConfigureAwait(false);
}
}
}
Expand Down
16 changes: 15 additions & 1 deletion src/PipelineNet/MiddlewareResolver/MiddlewareResolverResult.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace PipelineNet.MiddlewareResolver
using System;

namespace PipelineNet.MiddlewareResolver
{
/// <summary>
/// Contains the result of <see cref="IMiddlewareResolver"/>.
Expand All @@ -10,6 +12,18 @@ public class MiddlewareResolverResult
/// </summary>
public object Middleware { get; set; }

/// <summary>
/// Gets or sets the value indicating whether the middleware should be disposed.
/// Set this to <see langword="true"/> if the middleware is not disposed
/// by a dependency injection container.
/// </summary>
[Obsolete("This property is obsolete. Use Dispose.")]
public bool IsDisposable
{
get => Dispose;
set => Dispose = value;
}

/// <summary>
/// Gets or sets the value indicating whether the middleware should be disposed.
/// Set this to <see langword="true"/> if the middleware is not disposed
Expand Down

0 comments on commit 0d592aa

Please sign in to comment.