105040 Update 更新中间件描述
This commit is contained in:
parent
ae37631d03
commit
6d135ba074
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace LFlow.Middleware
|
||||
{
|
||||
|
||||
public interface IMiddleware
|
||||
{
|
||||
/// <summary>
|
||||
|
|
@ -9,7 +10,7 @@ namespace LFlow.Middleware
|
|||
/// </summary>
|
||||
int Priority { get; }
|
||||
/// <summary>
|
||||
/// 入口
|
||||
/// 中间件执行入口
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="next"></param>
|
||||
|
|
|
|||
|
|
@ -4,6 +4,10 @@
|
|||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<OutputPath>../LFlow_Bin/</OutputPath>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
|
||||
<UseCommonOutputDirectory>true</UseCommonOutputDirectory>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -6,14 +6,14 @@ namespace LFlow.Middleware.Register
|
|||
{
|
||||
public static class MiddlewareRegister
|
||||
{
|
||||
private static IServiceProvider _serviceProvider;
|
||||
private static IServiceProvider? _serviceProvider;
|
||||
|
||||
private static readonly IDictionary<Type, IMiddleware> _middlewares = new Dictionary<Type, IMiddleware>();
|
||||
private static List<Type> _middlewareTypes = [];
|
||||
public static void RegisterMiddlewares(this IServiceCollection service, List<Assembly> assemblys)
|
||||
public static void RegisterMiddlewares(this IServiceCollection service, List<Assembly> assemblies)
|
||||
{
|
||||
//var assembly = Assembly.getas()!;
|
||||
assemblys.ForEach(assembly =>
|
||||
assemblies.ForEach(assembly =>
|
||||
{
|
||||
var types = assembly.GetTypes().ToList();
|
||||
foreach (var type in types)
|
||||
|
|
@ -47,7 +47,7 @@ namespace LFlow.Middleware.Register
|
|||
var orderedMiddlewares = _middlewares.Values.OrderBy(m => m.Priority).ToList();
|
||||
foreach (var middleware in orderedMiddlewares)
|
||||
{
|
||||
application.Use(middleware.RunAsync);
|
||||
await Task.FromResult(application.Use(middleware.RunAsync));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue