Welcome to HamedStack.MessageBus! This repository provides a lightweight and flexible mediator implementation for .NET applications. It offers a clean approach to the mediator pattern, enabling decoupled communication between components through commands, queries, and events.
- Lightweight Design: Minimal overhead for high performance.
- Decoupled Communication: Components communicate without direct references.
- Support for Commands, Queries, and Events: Flexible handling of different message types.
- Easy Integration: Works seamlessly with existing .NET applications.
- Event Handlers: Support for publish-subscribe patterns.
To get started with HamedStack.MessageBus, you will need to have .NET installed on your machine. You can download the latest version of .NET from the official Microsoft website.
You can install HamedStack.MessageBus via NuGet. Run the following command in your terminal:
dotnet add package HamedStack.MessageBus
Alternatively, you can download the latest release from our Releases section. This will provide you with the necessary files to integrate into your project.
After installation, you can start using HamedStack.MessageBus in your application. Below is a basic example of how to set up the mediator and use it to send commands and queries.
-
Create a Mediator Instance:
var mediator = new Mediator();
-
Define Commands and Queries:
public class MyCommand : ICommand { public string Data { get; set; } } public class MyQuery : IQuery<string> { public int Id { get; set; } }
-
Create Handlers:
public class MyCommandHandler : ICommandHandler<MyCommand> { public Task Handle(MyCommand command) { // Handle command return Task.CompletedTask; } } public class MyQueryHandler : IQueryHandler<MyQuery, string> { public Task<string> Handle(MyQuery query) { // Handle query and return result return Task.FromResult("Result"); } }
-
Send Commands and Queries:
await mediator.Send(new MyCommand { Data = "Test" }); var result = await mediator.Send(new MyQuery { Id = 1 });
To see more examples of how to use HamedStack.MessageBus, please refer to the Examples
folder in the repository. You will find detailed implementations for various use cases, including:
- Sending commands
- Handling events
- Querying data
We welcome contributions to HamedStack.MessageBus! If you would like to contribute, please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature/YourFeature
). - Make your changes and commit them (
git commit -m 'Add new feature'
). - Push to the branch (
git push origin feature/YourFeature
). - Create a pull request.
Please ensure your code adheres to the existing coding standards and includes appropriate tests.
HamedStack.MessageBus is licensed under the MIT License. See the LICENSE file for more details.
For any questions or suggestions, feel free to reach out via GitHub issues or contact me directly.
You can find the latest releases of HamedStack.MessageBus here. Make sure to download the necessary files and execute them as needed.
Thank you for your interest in HamedStack.MessageBus! We hope you find it useful for your .NET applications. Happy coding!