CCSWE.nanoFramework.Mediator 1.1.74

dotnet add package CCSWE.nanoFramework.Mediator --version 1.1.74
                    
NuGet\Install-Package CCSWE.nanoFramework.Mediator -Version 1.1.74
                    
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.74" />
                    
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.74" />
                    
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.74
                    
#r "nuget: CCSWE.nanoFramework.Mediator, 1.1.74"
                    
#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.1.74
                    
Install CCSWE.nanoFramework.Mediator as a Cake Addin
#tool nuget:?package=CCSWE.nanoFramework.Mediator&version=1.1.74
                    
Install CCSWE.nanoFramework.Mediator 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.74 115 4/2/2025
1.1.73 111 3/26/2025
1.1.72 140 3/19/2025
1.1.71 86 3/14/2025
1.1.69 152 3/11/2025
1.1.68 153 3/11/2025
1.1.67 200 3/6/2025
1.1.66 207 3/3/2025
1.1.65 111 2/27/2025
1.1.64 90 2/26/2025
1.1.63 91 2/10/2025
1.1.62 92 2/10/2025
1.1.61 101 2/10/2025
1.1.56 91 2/7/2025
1.1.55 85 2/7/2025
1.1.54 89 2/7/2025
1.1.53 86 2/6/2025
1.1.52 98 2/6/2025
1.1.51 95 2/6/2025
1.1.50 85 2/6/2025
1.1.49 92 2/6/2025
1.1.48 90 2/5/2025
1.1.47 85 2/5/2025
1.1.46 86 2/5/2025
1.1.45 91 2/4/2025
1.1.44 91 2/4/2025
1.1.43 98 2/4/2025
1.1.42 101 2/4/2025
1.1.41 84 2/3/2025
1.1.40 88 2/3/2025
1.1.39 80 2/3/2025
1.1.37 93 2/3/2025
1.1.36 91 2/2/2025
1.1.35 85 2/2/2025
1.1.33 92 2/2/2025
1.1.29 98 1/31/2025
1.1.27 85 1/17/2025
1.1.24 88 1/17/2025
1.1.22 92 1/13/2025
1.1.21 85 1/12/2025
1.1.20 85 1/12/2025
1.1.19 82 1/12/2025
1.1.18 91 1/11/2025
1.1.17 80 1/11/2025
1.0.79 95 1/10/2025
1.0.78 89 1/9/2025
1.0.77 102 1/2/2025
1.0.76 95 12/26/2024
1.0.75 93 12/19/2024
1.0.74 131 12/12/2024
1.0.73 98 12/5/2024
1.0.72 102 11/28/2024
1.0.71 92 10/31/2024
1.0.70 99 10/24/2024
1.0.69 104 10/10/2024
1.0.68 96 10/3/2024
1.0.67 96 9/26/2024
1.0.66 98 9/23/2024
1.0.65 101 9/22/2024
1.0.64 95 9/21/2024
1.0.63 123 9/21/2024
1.0.62 137 9/14/2024
1.0.61 124 9/13/2024
1.0.59 111 9/2/2024
1.0.58 108 9/1/2024
1.0.57 106 8/31/2024
1.0.56 106 8/31/2024
1.0.55 132 8/14/2024
1.0.54 130 8/13/2024
1.0.53 118 8/11/2024
1.0.52 115 8/11/2024
1.0.51 120 8/8/2024
1.0.50 109 8/7/2024
1.0.49 117 8/6/2024
1.0.48 88 8/4/2024
1.0.47 87 8/3/2024
1.0.46 98 8/2/2024
1.0.45 99 8/2/2024
1.0.44 89 7/29/2024
1.0.43 79 7/27/2024
1.0.42 94 7/26/2024
1.0.41 91 7/25/2024
1.0.40 102 7/24/2024
1.0.39 116 7/19/2024
1.0.38 107 7/17/2024
1.0.37 102 7/15/2024
1.0.36 95 7/14/2024
1.0.35 112 7/13/2024
1.0.34 109 7/12/2024
1.0.33 130 6/16/2024
1.0.32 111 6/14/2024
1.0.31 109 6/13/2024
1.0.27 116 6/7/2024
1.0.26 116 6/6/2024
1.0.25 109 6/5/2024
1.0.24 110 6/5/2024
1.0.22 114 5/25/2024
1.0.21 119 5/24/2024
1.0.20 108 5/23/2024
1.0.19 123 5/21/2024
1.0.18 122 5/20/2024
1.0.17 111 5/19/2024
1.0.16 123 5/19/2024
1.0.15 122 5/19/2024
1.0.14 116 5/18/2024
1.0.12 112 5/16/2024
1.0.11 124 5/15/2024
1.0.10 96 5/13/2024
1.0.9 106 5/11/2024
1.0.8 107 5/10/2024
1.0.7 116 4/27/2024
1.0.6 117 4/26/2024
1.0.5 117 4/25/2024
1.0.4 115 4/25/2024
1.0.3 132 4/23/2024
1.0.2 123 4/20/2024
1.0.1 123 4/19/2024
1.0.0 129 4/19/2024
0.3.31 119 4/17/2024
0.3.30 131 4/13/2024
0.3.29 105 4/12/2024
0.3.28 123 4/11/2024
0.3.27 116 4/10/2024
0.3.26 116 4/9/2024
0.3.25 118 4/8/2024
0.3.24 101 4/7/2024
0.3.23 129 4/6/2024
0.3.22 116 4/5/2024
0.3.21 112 4/4/2024
0.3.20 114 4/3/2024
0.3.19 124 3/24/2024
0.3.18 129 3/22/2024
0.3.17 114 3/21/2024
0.3.16 158 2/6/2024
0.3.15 121 2/3/2024
0.3.14 118 2/1/2024
0.3.13 110 1/27/2024
0.3.12 108 1/26/2024
0.3.11 249 11/23/2023
0.3.10 138 11/22/2023
0.3.9 141 11/21/2023
0.3.8 154 11/17/2023
0.3.7 154 11/14/2023
0.3.6 133 11/13/2023
0.3.5 142 11/12/2023
0.3.4 137 11/12/2023
0.3.3 131 11/12/2023
0.3.2 129 11/12/2023
0.3.1 146 11/10/2023
0.3.0 138 11/10/2023
0.2.14 146 11/9/2023
0.2.13 142 11/8/2023
0.2.12 130 11/7/2023
0.2.10 153 11/7/2023
0.2.9 192 11/6/2023
0.2.7 192 11/6/2023
0.2.6 162 11/4/2023
0.2.5 155 11/3/2023
0.2.4 148 11/2/2023
0.2.3 146 11/2/2023
0.2.2 152 11/2/2023
0.2.1 144 10/30/2023
0.2.0 135 10/30/2023
0.1.8 164 10/28/2023
0.1.7 146 10/24/2023
0.1.6 146 10/24/2023
0.1.5 165 10/24/2023
0.1.4 161 10/24/2023
0.1.3 159 10/20/2023
0.1.2-beta 148 10/20/2023
0.1.1-beta 143 10/20/2023