SH.Mediator 1.1.9

dotnet add package SH.Mediator --version 1.1.9
                    
NuGet\Install-Package SH.Mediator -Version 1.1.9
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SH.Mediator" Version="1.1.9" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SH.Mediator" Version="1.1.9" />
                    
Directory.Packages.props
<PackageReference Include="SH.Mediator" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SH.Mediator --version 1.1.9
                    
#r "nuget: SH.Mediator, 1.1.9"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SH.Mediator@1.1.9
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SH.Mediator&version=1.1.9
                    
Install as a Cake Addin
#tool nuget:?package=SH.Mediator&version=1.1.9
                    
Install as a Cake Tool

<center> 使用方式

请您等他升级到 2.0 版本后再使用

安装 NuGet 包

dotnet add package SHMediator

注册服务

using SHMediator;
using Microsoft.Extensions.DependencyInjection;
var services = new ServiceCollection();
services.AddSHMediator(typeof(Program).Assembly);

三种 接口

1. IRequest       --  IRequestHandler
2. IRequest<,>    --  IRequestHandler<,>
3. INotification  --  INotificationHandler

1. IRequest -- IRequestHandler

public class MyRequest : IRequest<MyResponse>
{
	public string Name { get; set; }
}
public class MyResponse
{
	public string Message { get; set; }
}
public class MyRequestHandler : IRequestHandler<MyRequest, MyResponse>
{
	public Task<MyResponse> Handle(MyRequest request, CancellationToken cancellationToken)
	{
		return Task.FromResult(new MyResponse { Message = $"Hello, {request.Name}!" });
	}
}
// 使用
var mediator = serviceProvider.GetRequiredService<IMediator>();
var response = await mediator.Send(new MyRequest { Name = "World" });
Console.WriteLine(response.Message); // 输出: Hello, World!

2. INotification -- INotificationHandler

public class MyNotify : INotification
{
	public string Name { get; set; }
}

public class MyNotify1Handlder : INotificationHandler<MyNotify>
{
	 Task Handle(TNotification notification)
	 {
	     Console.WriteLine("")
	 }
}
public class MyNotify2Handlder : INotificationHandler<MyNotify>
{
	 Task Handle(TNotification notification)
	 {
	     Console.WriteLine("")
	 }
}

更新内容

  • 添加自动注册验证Validator功能
  • 更新添加拦截器 并支持自定义

文档目录

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.9 86 1/30/2026
1.1.8 93 1/23/2026
1.1.7 93 1/23/2026
1.1.6 94 1/22/2026
1.1.5 101 1/22/2026
1.1.4 99 1/22/2026
1.1.3 88 1/22/2026
1.0.1 92 1/21/2026
1.0.0 97 1/21/2026