Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork0
Streamline your application’s event-driven architecture. ReflectionEventing enables easy event handling in .NET applications through dependency injection, promoting loose coupling and increased modularity.
License
MIT, MIT licenses found
Licenses found
lepoco/reflectioneventing
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
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.
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
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
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.DependencyInjectionIn 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.
IHosthost=Host.CreateDefaultBuilder().ConfigureServices((context,services)=>{services.AddSingleton<MainWindowViewModel>();services.AddEventBus(e=>{e.AddConsumer<MainWindowViewModel>();});}).Build();
By default, when multiple consumers are registered for the same event, they are executed in parallel. You can configure the execution mode to be sequential if you need consumers to execute one at a time in order:
services.AddEventBus(e=>{e.AddConsumer<FirstConsumer>();e.AddConsumer<SecondConsumer>();e.AddConsumer<ThirdConsumer>();// Configure sequential execution (default is Parallel)e.Options.ConsumerExecutionMode=ProcessingMode.Sequential;});
Execution Modes:
ProcessingMode.Parallel(default) - Consumers execute concurrently usingTask.WhenAllProcessingMode.Sequential- Consumers execute one at a time in registration order
Use sequential mode when:
- Order of execution matters for your business logic
- Consumers modify shared state that should not be accessed concurrently
- You need predictable execution flow for testing or debugging
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 aBackgroundTicked event.
publicclassMyBackgroundService(IEventBuseventBus){publicvoidPublishEvent(){eventBus.Publish(newBackgroundTicked());}}
Finally, we implement theIConsumer<T> interface in our ViewModel. This allows the ViewModel to consumeBackgroundTicked events. When aBackgroundTicked event is published, theConsumeAsync method is called, and we update theCurrentTick property.
publicpartialclassMainWindowViewModel:ObservableObject,IConsumer<BackgroundTicked>{[ObservableProperty]privateint_currentTick=0;publicValueTaskConsumeAsync(BackgroundTickedpayload,CancellationTokencancellationToken){CurrentTick=payload.Value;returnValueTask.CompletedTask;}}
JetBrains was kind enough to lend a license for the open-sourcedotUltimate forReflectionEventing development.
Learn more here:
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.
This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community.
ReflectionEventing is free and open source software licensed underMIT 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.
About
Streamline your application’s event-driven architecture. ReflectionEventing enables easy event handling in .NET applications through dependency injection, promoting loose coupling and increased modularity.
Topics
Resources
License
MIT, MIT licenses found
Licenses found
Code of conduct
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.