-
Notifications
You must be signed in to change notification settings - Fork 3
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
12 changed files
with
51 additions
and
20 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using OfX.Attributes; | ||
using OfX.Responses; | ||
|
||
namespace OfX.Abstractions; | ||
|
||
public interface IReceivedPipelinesBase<TAttribute> where TAttribute : OfXAttribute | ||
{ | ||
Task<ItemsResponse<OfXDataResponse>> ExecuteAsync(RequestContext<TAttribute> requestContext); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using OfX.Abstractions; | ||
using OfX.Attributes; | ||
using OfX.Cached; | ||
using OfX.Responses; | ||
|
||
namespace OfX.Implementations; | ||
|
||
internal sealed class SendPipelineRoutingBehavior<TAttribute>( | ||
IServiceProvider serviceProvider) : | ||
ISendPipelineBehavior<TAttribute> where TAttribute : OfXAttribute | ||
{ | ||
public async Task<ItemsResponse<OfXDataResponse>> HandleAsync(RequestContext<TAttribute> requestContext, | ||
Func<Task<ItemsResponse<OfXDataResponse>>> next) | ||
{ | ||
// Check if we have the inner handler for `TAttribute` or not. If have, we will call the ReceivedPipelinesImpl<,> instead of sending via message! | ||
var existedHandler = OfXCached.AttributeMapHandler; | ||
if (!existedHandler.TryGetValue(typeof(TAttribute), out var handlerType)) return await next.Invoke(); | ||
if (!handlerType.IsGenericType) return await next.Invoke(); | ||
var args = handlerType.GetGenericArguments(); | ||
var receivedPipelineBehavior = serviceProvider | ||
.GetService(typeof(ReceivedPipelinesImpl<,>).MakeGenericType(args)); | ||
if (receivedPipelineBehavior is not IReceivedPipelinesBase<TAttribute> receivedPipelinesBase) | ||
return await next.Invoke(); | ||
return await receivedPipelinesBase.ExecuteAsync(requestContext); | ||
} | ||
} |
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