ReflectionEventing.Ninject 3.1.0

dotnet add package ReflectionEventing.Ninject --version 3.1.0                
NuGet\Install-Package ReflectionEventing.Ninject -Version 3.1.0                
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="ReflectionEventing.Ninject" Version="3.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ReflectionEventing.Ninject --version 3.1.0                
#r "nuget: ReflectionEventing.Ninject, 3.1.0"                
#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.
// Install ReflectionEventing.Ninject as a Cake Addin
#addin nuget:?package=ReflectionEventing.Ninject&version=3.1.0

// Install ReflectionEventing.Ninject as a Cake Tool
#tool nuget:?package=ReflectionEventing.Ninject&version=3.1.0                

🚎 ReflectionEventing

Created with ❤ in Poland by lepo.co
ReflectionEventing is a powerful tool for developers looking to create decoupled designs in WPF, WinForms, or CLI applications. By leveraging the power of Dependency Injection (DI) and eventing, ReflectionEventing promotes better Inversion of Control (IoC), reducing coupling and enhancing the modularity and flexibility of your applications.

GitHub license Nuget Nuget Sponsors

👀 What does this repo contain?

This repository houses the source code for the ReflectionEventing NuGet package. The package utilizes C# reflection to register services that can listen for and respond to local events.

🛟 Support plans

To ensure you receive the expert guidance you need, we offer a variety of support plans designed to meet the diverse needs of our community. Whether you are looking to in memory eventing or need assistance with our other libraries, our tailored support solutions are here to help. From priority email support to 24/7 dedicated assistance, we provide flexible plans to suit your project requirements.

Take a look at the lepo.co support plans

🤝 Help us keep working on this project

Support the development of Reflection Eventing and other innovative projects by becoming a sponsor on GitHub! Your monthly or one-time contributions help us continue to deliver high-quality, open-source solutions that empower developers worldwide.

Sponsor Reflection Eventing on GitHub

Gettings started

ReflectionEventing is available as NuGet package on NuGet.org:
https://www.nuget.org/packages/ReflectionEventing
https://www.nuget.org/packages/ReflectionEventing.Autofac
https://www.nuget.org/packages/ReflectionEventing.Castle.Windsor
https://www.nuget.org/packages/ReflectionEventing.DependencyInjection
https://www.nuget.org/packages/ReflectionEventing.Ninject
https://www.nuget.org/packages/ReflectionEventing.Unity

You can add it to your project using .NET CLI:

dotnet add package ReflectionEventing.DependencyInjection

, or package manager console:

NuGet\Install-Package ReflectionEventing.DependencyInjection

🛠️ How to Use ReflectionEventing

1. Register Consumers and the Event Bus

In this step, we register our ViewModel as a singleton and add it as a consumer to the event bus. This allows the ViewModel to listen for events published on the bus.

IHost host = Host.CreateDefaultBuilder()
  .ConfigureServices((context, services) =>
    {
      services.AddSingleton<MainWindowViewModel>();
      services.AddEventBus(e =>
      {
        e.AddConsumer<MainWindowViewModel>();
      });
    }
  )
  .Build();
2. Publish Events

Here, we create a background service that publishes an event on the event bus. This event could be anything - in this case, we're publishing a BackgroundTicked event.

public class MyBackgroundService(IEventBus eventBus)
{
    public void PublishEvent()
    {
        eventBus.Publish(new BackgroundTicked());
    }
}
3. Listen for Events

Finally, we implement the IConsumer<T> interface in our ViewModel. This allows the ViewModel to consume BackgroundTicked events. When a BackgroundTicked event is published, the ConsumeAsync method is called, and we update the CurrentTick property.

public partial class MainWindowViewModel : ObservableObject, IConsumer<BackgroundTicked>
{
    [ObservableProperty]
    private int _currentTick = 0;

    public Task ConsumeAsync(BackgroundTicked payload, CancellationToken cancellationToken)
    {
        CurrentTick = payload.Value;

        return Task.CompletedTask;
    }
}

Special thanks

JetBrains was kind enough to lend a license for the open-source dotUltimate for ReflectionEventing development.
Learn more here:

Compilation

To build the project, use Visual Studio 2022 and open the .sln file.

Visual Studio
ReflectionEventing is an Open Source project. You are entitled to download and use the freely available Visual Studio Community Edition to build, run or develop for ReflectionEventing. As per the Visual Studio Community Edition license, this applies regardless of whether you are an individual or a corporate user.

Code of Conduct

This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community.

License

ReflectionEventing is free and open source software licensed under MIT License. You can use it in private and commercial projects.
Keep in mind that you must include a copy of the license in your project.

Product Compatible and additional computed target framework versions.
.NET Framework net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 is compatible.  net48 was computed.  net481 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
3.1.0 95 9/19/2024
3.0.2 119 8/11/2024
3.0.1 123 6/1/2024
3.0.0 108 5/31/2024
2.2.0 125 5/20/2024 2.2.0 is deprecated because it is no longer maintained.
2.1.0 129 5/18/2024 2.1.0 is deprecated because it has critical bugs.