CCSWE.nanoFramework.Mediator 1.0.62

There is a newer version of this package available.
See the version list below for details.
dotnet add package CCSWE.nanoFramework.Mediator --version 1.0.62
                    
NuGet\Install-Package CCSWE.nanoFramework.Mediator -Version 1.0.62
                    
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.0.62" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CCSWE.nanoFramework.Mediator" Version="1.0.62" />
                    
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.0.62
                    
#r "nuget: CCSWE.nanoFramework.Mediator, 1.0.62"
                    
#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.
#addin nuget:?package=CCSWE.nanoFramework.Mediator&version=1.0.62
                    
Install as a Cake Addin
#tool nuget:?package=CCSWE.nanoFramework.Mediator&version=1.0.62
                    
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 : 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 Compatible and additional computed target framework versions.
.NET Framework net 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.83 55 7/7/2025
1.1.82 274 6/9/2025
1.1.81 270 6/9/2025
1.1.79 134 4/29/2025
1.1.78 161 4/28/2025
1.1.77 169 4/24/2025
1.1.75 207 4/17/2025
1.1.74 180 4/2/2025
1.1.73 148 3/26/2025
1.1.72 166 3/19/2025
1.1.71 112 3/14/2025
1.1.69 179 3/11/2025
1.1.68 182 3/11/2025
1.1.67 227 3/6/2025
1.1.66 238 3/3/2025
1.1.65 139 2/27/2025
1.1.64 120 2/26/2025
1.1.63 116 2/10/2025
1.1.62 120 2/10/2025
1.1.61 127 2/10/2025
1.1.56 117 2/7/2025
1.1.55 115 2/7/2025
1.1.54 117 2/7/2025
1.1.53 110 2/6/2025
1.1.52 122 2/6/2025
1.1.51 123 2/6/2025
1.1.50 112 2/6/2025
1.1.49 117 2/6/2025
1.1.48 113 2/5/2025
1.1.47 110 2/5/2025
1.1.46 109 2/5/2025
1.1.45 123 2/4/2025
1.1.44 120 2/4/2025
1.1.43 123 2/4/2025
1.1.42 128 2/4/2025
1.1.41 112 2/3/2025
1.1.40 112 2/3/2025
1.1.39 108 2/3/2025
1.1.37 115 2/3/2025
1.1.36 119 2/2/2025
1.1.35 112 2/2/2025
1.1.33 118 2/2/2025
1.1.29 122 1/31/2025
1.1.27 106 1/17/2025
1.1.24 110 1/17/2025
1.1.22 114 1/13/2025
1.1.21 106 1/12/2025
1.1.20 108 1/12/2025
1.1.19 106 1/12/2025
1.1.18 112 1/11/2025
1.1.17 103 1/11/2025
1.0.79 118 1/10/2025
1.0.78 111 1/9/2025
1.0.77 124 1/2/2025
1.0.76 116 12/26/2024
1.0.75 114 12/19/2024
1.0.74 155 12/12/2024
1.0.73 119 12/5/2024
1.0.72 126 11/28/2024
1.0.71 114 10/31/2024
1.0.70 119 10/24/2024
1.0.69 125 10/10/2024
1.0.68 117 10/3/2024
1.0.67 121 9/26/2024
1.0.66 119 9/23/2024
1.0.65 122 9/22/2024
1.0.64 119 9/21/2024
1.0.63 147 9/21/2024
1.0.62 163 9/14/2024
1.0.61 145 9/13/2024
1.0.59 134 9/2/2024
1.0.58 131 9/1/2024
1.0.57 128 8/31/2024
1.0.56 127 8/31/2024
1.0.55 154 8/14/2024
1.0.54 152 8/13/2024
1.0.53 141 8/11/2024
1.0.52 134 8/11/2024
1.0.51 141 8/8/2024
1.0.50 130 8/7/2024
1.0.49 144 8/6/2024
1.0.48 113 8/4/2024
1.0.47 113 8/3/2024
1.0.46 121 8/2/2024
1.0.45 121 8/2/2024
1.0.44 115 7/29/2024
1.0.43 103 7/27/2024
1.0.42 115 7/26/2024
1.0.41 114 7/25/2024
1.0.40 122 7/24/2024
1.0.39 138 7/19/2024
1.0.38 128 7/17/2024
1.0.37 126 7/15/2024
1.0.36 118 7/14/2024
1.0.35 137 7/13/2024
1.0.34 132 7/12/2024
1.0.33 154 6/16/2024
1.0.32 133 6/14/2024
1.0.31 131 6/13/2024
1.0.27 141 6/7/2024
1.0.26 138 6/6/2024
1.0.25 132 6/5/2024
1.0.24 132 6/5/2024
1.0.22 138 5/25/2024
1.0.21 139 5/24/2024
1.0.20 128 5/23/2024
1.0.19 143 5/21/2024
1.0.18 142 5/20/2024
1.0.17 131 5/19/2024
1.0.16 144 5/19/2024
1.0.15 143 5/19/2024
1.0.14 140 5/18/2024
1.0.12 135 5/16/2024
1.0.11 144 5/15/2024
1.0.10 123 5/13/2024
1.0.9 133 5/11/2024
1.0.8 127 5/10/2024
1.0.7 136 4/27/2024
1.0.6 138 4/26/2024
1.0.5 138 4/25/2024
1.0.4 137 4/25/2024
1.0.3 156 4/23/2024
1.0.2 148 4/20/2024
1.0.1 152 4/19/2024
1.0.0 150 4/19/2024
0.3.31 142 4/17/2024
0.3.30 153 4/13/2024
0.3.29 124 4/12/2024
0.3.28 143 4/11/2024
0.3.27 137 4/10/2024
0.3.26 137 4/9/2024
0.3.25 143 4/8/2024
0.3.24 124 4/7/2024
0.3.23 151 4/6/2024
0.3.22 139 4/5/2024
0.3.21 134 4/4/2024
0.3.20 135 4/3/2024
0.3.19 147 3/24/2024
0.3.18 152 3/22/2024
0.3.17 135 3/21/2024
0.3.16 179 2/6/2024
0.3.15 142 2/3/2024
0.3.14 141 2/1/2024
0.3.13 131 1/27/2024
0.3.12 134 1/26/2024
0.3.11 261 11/23/2023
0.3.10 148 11/22/2023
0.3.9 153 11/21/2023
0.3.8 165 11/17/2023
0.3.7 169 11/14/2023
0.3.6 146 11/13/2023
0.3.5 152 11/12/2023
0.3.4 148 11/12/2023
0.3.3 144 11/12/2023
0.3.2 140 11/12/2023
0.3.1 161 11/10/2023
0.3.0 148 11/10/2023
0.2.14 155 11/9/2023
0.2.13 159 11/8/2023
0.2.12 147 11/7/2023
0.2.10 163 11/7/2023
0.2.9 201 11/6/2023
0.2.7 205 11/6/2023
0.2.6 172 11/4/2023
0.2.5 164 11/3/2023
0.2.4 158 11/2/2023
0.2.3 155 11/2/2023
0.2.2 166 11/2/2023
0.2.1 156 10/30/2023
0.2.0 149 10/30/2023
0.1.8 176 10/28/2023
0.1.7 165 10/24/2023
0.1.6 164 10/24/2023
0.1.5 183 10/24/2023
0.1.4 178 10/24/2023
0.1.3 178 10/20/2023
0.1.2-beta 165 10/20/2023
0.1.1-beta 159 10/20/2023