CCSWE.nanoFramework.Mediator 1.1.161

dotnet add package CCSWE.nanoFramework.Mediator --version 1.1.161
                    
NuGet\Install-Package CCSWE.nanoFramework.Mediator -Version 1.1.161
                    
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="CCSWE.nanoFramework.Mediator" Version="1.1.161" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CCSWE.nanoFramework.Mediator" Version="1.1.161" />
                    
Directory.Packages.props
<PackageReference Include="CCSWE.nanoFramework.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 CCSWE.nanoFramework.Mediator --version 1.1.161
                    
#r "nuget: CCSWE.nanoFramework.Mediator, 1.1.161"
                    
#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 CCSWE.nanoFramework.Mediator@1.1.161
                    
#: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=CCSWE.nanoFramework.Mediator&version=1.1.161
                    
Install as a Cake Addin
#tool nuget:?package=CCSWE.nanoFramework.Mediator&version=1.1.161
                    
Install as a Cake Tool

Build License NuGet

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
{
    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 IServiceCollection

    var serviceCollection = new ServiceCollection();
    serviceCollection.AddSingleton(typeof(EventHandlerService));
    serviceCollection.AddMediator(options =>
    {
        options.AddSubscriber(typeof(Event1), typeof(EventHandlerService));
        options.AddSubscriber(typeof(Event2), typeof(EventHandlerService));
    });

For transient and scoped services you can use the Subscribe and Unsubscribe overloads that take a specific instance.

public class TransientService : IMediatorEventHandler, 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);
    }

    public void HandleEvent(IMediatorEvent mediatorEvent)
    {
        // ...
    }
}
Product Compatible and additional computed target framework versions.
.NETnanoFramework netnano1.0 is compatible. 
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.161 110 10/11/2026
1.1.159 109 10/10/2026
1.1.158 99 10/10/2026
1.1.155 99 10/10/2026
1.1.154 108 10/10/2026
1.1.153 92 10/10/2026
1.1.148 149 8/3/2026
1.1.147 142 7/31/2026
1.1.146 133 7/31/2026
1.1.145 151 7/17/2026
1.1.144 134 7/14/2026
1.1.143 142 7/11/2026
1.1.142 146 7/1/2026
1.1.141 146 6/30/2026
1.1.140 156 6/26/2026
1.1.139 149 6/24/2026
1.1.138 143 6/24/2026
1.1.137 156 6/24/2026
1.1.136 154 6/23/2026
1.1.135 141 6/1/2026
Loading failed