CCSWE.nanoFramework.Mediator 1.0.33

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.33
                    
NuGet\Install-Package CCSWE.nanoFramework.Mediator -Version 1.0.33
                    
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.33" />
                    
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.33" />
                    
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.33
                    
#r "nuget: CCSWE.nanoFramework.Mediator, 1.0.33"
                    
#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.0.33
                    
#: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.0.33
                    
Install as a Cake Addin
#tool nuget:?package=CCSWE.nanoFramework.Mediator&version=1.0.33
                    
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 166 7/7/2025
1.1.82 299 6/9/2025
1.1.81 296 6/9/2025
1.1.79 157 4/29/2025
1.1.78 175 4/28/2025
1.1.77 193 4/24/2025
1.1.75 230 4/17/2025
1.1.74 203 4/2/2025
1.1.73 171 3/26/2025
1.1.72 181 3/19/2025
1.1.71 137 3/14/2025
1.1.69 204 3/11/2025
1.1.68 209 3/11/2025
1.1.67 250 3/6/2025
1.1.66 260 3/3/2025
1.1.65 161 2/27/2025
1.1.64 133 2/26/2025
1.1.63 138 2/10/2025
1.1.62 142 2/10/2025
1.1.61 150 2/10/2025
1.1.56 131 2/7/2025
1.1.55 137 2/7/2025
1.1.54 139 2/7/2025
1.1.53 133 2/6/2025
1.1.52 143 2/6/2025
1.1.51 144 2/6/2025
1.1.50 134 2/6/2025
1.1.49 139 2/6/2025
1.1.48 135 2/5/2025
1.1.47 132 2/5/2025
1.1.46 131 2/5/2025
1.1.45 144 2/4/2025
1.1.44 142 2/4/2025
1.1.43 146 2/4/2025
1.1.42 142 2/4/2025
1.1.41 134 2/3/2025
1.1.40 135 2/3/2025
1.1.39 129 2/3/2025
1.1.37 137 2/3/2025
1.1.36 141 2/2/2025
1.1.35 135 2/2/2025
1.1.33 140 2/2/2025
1.1.29 143 1/31/2025
1.1.27 128 1/17/2025
1.1.24 131 1/17/2025
1.1.22 136 1/13/2025
1.1.21 127 1/12/2025
1.1.20 130 1/12/2025
1.1.19 129 1/12/2025
1.1.18 134 1/11/2025
1.1.17 128 1/11/2025
1.0.79 142 1/10/2025
1.0.78 135 1/9/2025
1.0.77 146 1/2/2025
1.0.76 138 12/26/2024
1.0.75 136 12/19/2024
1.0.74 182 12/12/2024
1.0.73 142 12/5/2024
1.0.72 150 11/28/2024
1.0.71 137 10/31/2024
1.0.70 142 10/24/2024
1.0.69 148 10/10/2024
1.0.68 141 10/3/2024
1.0.67 143 9/26/2024
1.0.66 141 9/23/2024
1.0.65 134 9/22/2024
1.0.64 140 9/21/2024
1.0.63 171 9/21/2024
1.0.62 185 9/14/2024
1.0.61 169 9/13/2024
1.0.59 147 9/2/2024
1.0.58 154 9/1/2024
1.0.57 150 8/31/2024
1.0.56 149 8/31/2024
1.0.55 177 8/14/2024
1.0.54 174 8/13/2024
1.0.53 164 8/11/2024
1.0.52 156 8/11/2024
1.0.51 164 8/8/2024
1.0.50 151 8/7/2024
1.0.49 165 8/6/2024
1.0.48 135 8/4/2024
1.0.47 137 8/3/2024
1.0.46 142 8/2/2024
1.0.45 134 8/2/2024
1.0.44 137 7/29/2024
1.0.43 126 7/27/2024
1.0.42 137 7/26/2024
1.0.41 136 7/25/2024
1.0.40 145 7/24/2024
1.0.39 161 7/19/2024
1.0.38 152 7/17/2024
1.0.37 147 7/15/2024
1.0.36 141 7/14/2024
1.0.35 160 7/13/2024
1.0.34 154 7/12/2024
1.0.33 176 6/16/2024
1.0.32 156 6/14/2024
1.0.31 153 6/13/2024
1.0.27 164 6/7/2024
1.0.26 160 6/6/2024
1.0.25 154 6/5/2024
1.0.24 154 6/5/2024
1.0.22 160 5/25/2024
1.0.21 160 5/24/2024
1.0.20 151 5/23/2024
1.0.19 163 5/21/2024
1.0.18 165 5/20/2024
1.0.17 154 5/19/2024
1.0.16 167 5/19/2024
1.0.15 164 5/19/2024
1.0.14 161 5/18/2024
1.0.12 157 5/16/2024
1.0.11 167 5/15/2024
1.0.10 146 5/13/2024
1.0.9 155 5/11/2024
1.0.8 149 5/10/2024
1.0.7 158 4/27/2024
1.0.6 160 4/26/2024
1.0.5 160 4/25/2024
1.0.4 159 4/25/2024
1.0.3 177 4/23/2024
1.0.2 169 4/20/2024
1.0.1 170 4/19/2024
1.0.0 172 4/19/2024
0.3.31 153 4/17/2024
0.3.30 175 4/13/2024
0.3.29 136 4/12/2024
0.3.28 166 4/11/2024
0.3.27 150 4/10/2024
0.3.26 159 4/9/2024
0.3.25 165 4/8/2024
0.3.24 147 4/7/2024
0.3.23 173 4/6/2024
0.3.22 161 4/5/2024
0.3.21 156 4/4/2024
0.3.20 147 4/3/2024
0.3.19 168 3/24/2024
0.3.18 174 3/22/2024
0.3.17 157 3/21/2024
0.3.16 201 2/6/2024
0.3.15 163 2/3/2024
0.3.14 161 2/1/2024
0.3.13 152 1/27/2024
0.3.12 154 1/26/2024
0.3.11 281 11/23/2023
0.3.10 166 11/22/2023
0.3.9 172 11/21/2023
0.3.8 186 11/17/2023
0.3.7 189 11/14/2023
0.3.6 167 11/13/2023
0.3.5 172 11/12/2023
0.3.4 167 11/12/2023
0.3.3 163 11/12/2023
0.3.2 159 11/12/2023
0.3.1 181 11/10/2023
0.3.0 167 11/10/2023
0.2.14 177 11/9/2023
0.2.13 179 11/8/2023
0.2.12 168 11/7/2023
0.2.10 183 11/7/2023
0.2.9 221 11/6/2023
0.2.7 226 11/6/2023
0.2.6 192 11/4/2023
0.2.5 185 11/3/2023
0.2.4 179 11/2/2023
0.2.3 177 11/2/2023
0.2.2 176 11/2/2023
0.2.1 177 10/30/2023
0.2.0 169 10/30/2023
0.1.8 197 10/28/2023
0.1.7 186 10/24/2023
0.1.6 185 10/24/2023
0.1.5 204 10/24/2023
0.1.4 198 10/24/2023
0.1.3 198 10/20/2023
0.1.2-beta 186 10/20/2023
0.1.1-beta 170 10/20/2023