-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
14 changed files
with
187 additions
and
108 deletions.
There are no files selected for viewing
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
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
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
This file was deleted.
Oops, something went wrong.
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,13 @@ | ||
namespace Shiny.Mediator; | ||
|
||
public interface IEventExceptionHandler | ||
{ | ||
Task Process(EventExceptionContext context); | ||
} | ||
|
||
public record EventExceptionContext( | ||
IEvent Event, | ||
Exception Exception, | ||
bool FireAndForget, // you may wish to propagate the exception out if events are being await for completion | ||
bool Handled | ||
); |
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,22 @@ | ||
namespace Shiny.Mediator; | ||
|
||
public interface IRequestExceptionrHandler | ||
{ | ||
// should this be abortable or even async? | ||
Task Handle(RequestExceptionContext context, CancellationToken cancellationToken); | ||
} | ||
|
||
// what about events? | ||
public class RequestExceptionContext | ||
{ | ||
public RequestExceptionContext(object request, Exception exception) | ||
{ | ||
this.Request = request; | ||
this.Exception = exception; | ||
} | ||
|
||
|
||
public object Request { get; } | ||
public Exception Exception { get; } | ||
public bool Handled { get; set; } | ||
} |
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 |
---|---|---|
@@ -1,10 +1,13 @@ | ||
// namespace Shiny.Mediator; | ||
// | ||
// public interface IRequestMiddle<TRequest> where TRequest : notnull, IRequest | ||
// { | ||
// Task Process(TRequest request, IRequestPipeline<TRequest> next, CancellationToken cancellationToken); | ||
// } | ||
// | ||
// | ||
// public record RequestDelegate(object Request); | ||
using Shiny.Mediator; | ||
|
||
// TODO: how do I register an "ALL" middleware | ||
|
||
// TODO: execution duration timer | ||
|
||
// TODO: catch all could be IRequest or IRequest<T>? Could use an IRequest<Void>? | ||
public interface IRequestMiddleware<TRequest, TResult> where TRequest : IRequest<TResult> | ||
{ | ||
// intercept with connectivity, if offline go to cache, if online go to remote | ||
// if went to remote, post execute stores to cache | ||
Task<TResult> Process(TRequest request, IRequestHandler<TRequest, TResult> handler); | ||
} |
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
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,9 @@ | ||
// namespace Shiny.Mediator.Middleware; | ||
// | ||
// public class TimedMiddleware<IRequest<TResult>> : IRequestMiddleware<IRequest<TResult>> | ||
// { | ||
// public Task Process(IRequest request, IRequestHandler<IRequest> handler) | ||
// { | ||
// throw new NotImplementedException(); | ||
// } | ||
// } |
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,6 @@ | ||
namespace Shiny.Mediator; | ||
|
||
public sealed class Unit | ||
{ | ||
public static Unit Value { get; } = new(); | ||
} |
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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
global using Xunit; | ||
global using Shiny.Mediator; | ||
global using Microsoft.Extensions.DependencyInjection; | ||
global using System.Diagnostics; | ||
global using FluentAssertions; |
Oops, something went wrong.