CCSWE.nanoFramework.Mediator
1.1.92
dotnet add package CCSWE.nanoFramework.Mediator --version 1.1.92
NuGet\Install-Package CCSWE.nanoFramework.Mediator -Version 1.1.92
<PackageReference Include="CCSWE.nanoFramework.Mediator" Version="1.1.92" />
<PackageVersion Include="CCSWE.nanoFramework.Mediator" Version="1.1.92" />
<PackageReference Include="CCSWE.nanoFramework.Mediator" />
paket add CCSWE.nanoFramework.Mediator --version 1.1.92
#r "nuget: CCSWE.nanoFramework.Mediator, 1.1.92"
#:package CCSWE.nanoFramework.Mediator@1.1.92
#addin nuget:?package=CCSWE.nanoFramework.Mediator&version=1.1.92
#tool nuget:?package=CCSWE.nanoFramework.Mediator&version=1.1.92
CCSWE.nanoFramework.Mediator
A simple asynchronous mediator implementation for nanoFramework. Provides in-process publisher-subscriber communication while keeping all parties decoupled.
Based on Mako-IoT.Device.Services.Mediator
Usage
Create classes for your events
public class Event1 : IMediatorEvent
{
public string Data { get; set; }
}
public class Event2 : IMediatorEvent
{
public string Text { get; set; }
}
Your event subscriber must implement IMediatorEventHandler interface
public class EventHandlerService : IMediatorEventHandler
{
public void HandleEvent(IMediatorEvent mediatorEvent)
{
switch (mediatorEvent)
{
case Event1 event1:
Debug.WriteLine($"[{nameof(EventHandlerService)}] Event1 received. The data is: {event1.Data}");
break;
case Event2 event2:
Debug.WriteLine($"[{nameof(EventHandlerService)}] Event2 received The text is: {event2.Text}");
break;
}
}
}
Use IMediator to publish events
public class EventPublisherService : IEventPublisherService
{
private readonly IMediator _mediator;
public EventPublisherService(IMediator mediator)
{
_mediator = mediator;
}
public void DoSomething()
{
_mediator.Publish(new Event2 { Text = "Hello from EventPublisherService" });
}
}
Register AsyncMediator and singleton subscribers to an IHostBuilder ...
var hostBuilder = new HostBuilder();
hostBuilder.UseMediator(options =>
{
options.AddSubscriber(typeof(Event1), typeof(Service2));
options.AddSubscriber(typeof(Event2), typeof(Service2));
});
... or directly to an IServiceCollection
var serviceCollection = new ServiceCollection();
serviceCollection.AddMediator(options =>
{
options.AddSubscriber(typeof(Event1), typeof(Service2));
options.AddSubscriber(typeof(Event2), typeof(Service2));
});
For transient and scoped services you can use the Subscribe and Unsubscribe overloads that take a specific instance.
public class TransientService : IDisposable
{
private readonly IMediator _mediator;
public TransientService(IMediator mediator)
{
_mediator = mediator;
_mediator.Subscribe(typeof(Event1), this);
_mediator.Subscribe(typeof(Event2), this);
}
public void Dispose()
{
_mediator.Unsubscribe(typeof(Event1), this);
_mediator.Unsubscribe(typeof(Event2), this);
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NETnanoFramework | netnano1.0 is compatible. |
-
- CCSWE.nanoFramework.Core (>= 1.1.92)
- CCSWE.nanoFramework.Threading (>= 1.1.92)
- nanoFramework.CoreLibrary (>= 1.17.11)
- nanoFramework.DependencyInjection (>= 1.1.32)
- nanoFramework.Logging (>= 1.1.161)
- nanoFramework.System.Collections (>= 1.5.67)
- nanoFramework.System.Threading (>= 1.1.52)
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.92 | 102 | 3/2/2026 |
| 1.1.91 | 87 | 2/28/2026 |
| 1.1.90 | 87 | 2/27/2026 |
| 1.1.89 | 90 | 2/27/2026 |
| 1.1.88 | 86 | 2/23/2026 |
| 1.1.86 | 226 | 11/6/2025 |
| 1.1.84 | 161 | 10/3/2025 |
| 1.1.83 | 246 | 7/7/2025 |
| 1.1.82 | 367 | 6/9/2025 |
| 1.1.81 | 355 | 6/9/2025 |
| 1.1.79 | 219 | 4/29/2025 |
| 1.1.78 | 246 | 4/28/2025 |
| 1.1.77 | 251 | 4/24/2025 |
| 1.1.75 | 292 | 4/17/2025 |
| 1.1.74 | 276 | 4/2/2025 |
| 1.1.73 | 227 | 3/26/2025 |
| 1.1.72 | 241 | 3/19/2025 |
| 1.1.71 | 197 | 3/14/2025 |
| 1.1.69 | 263 | 3/11/2025 |
| 1.1.68 | 273 | 3/11/2025 |