From 9385f05367b4e70e2855e4d4f5b72183fe1b279c Mon Sep 17 00:00:00 2001 From: Louis Seubert Date: Fri, 8 May 2026 20:53:23 +0200 Subject: [PATCH] chore: update readme with basic information --- README.md | 72 +++++++++++++++++++++++++++++++++++ src/Request/package-readme.md | 65 +++++++++++++++++++++++++++++++ 2 files changed, 137 insertions(+) diff --git a/README.md b/README.md index e69de29..30ebd7d 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,72 @@ +# `Geekeey.Request` + +Simple mediator implementation in .NET with minimal dependencies. + +## Features + +- **Simple interfaces:** no complex constraints, just marker interfaces that work. +- **Minmal dependencies:** only depends on `Microsoft.Extensions.DependencyInjection.Abstractions` and the + `Microsoft.Extensions.Options` package. + +## Getting Started + +### Install the NuGet package: + +```shell +dotnet add package Geekeey.Request +``` + +You may need to add our NuGet feed to your `nuget.config` this can be done by running the following command: + +```shell +dotnet nuget add source -n geekeey https://code.geekeey.de/api/packages/geekeey/nuget/index.json +``` + +### Usage + +```csharp +public static Task Main() +{ + var collection = new ServiceCollection(); + collection.AddRequestDispatcher(builder => builder + .Add(typeof(ScalarHandler)) + .Add(typeof(ScalarBehavior))); + await using var provider = collection.BuildServiceProvider(); + var dispatcher = provider.GetRequiredService(); + + var request = new ScalarRequest { Value = "Hello" }; + var result = await dispatcher.DispatchAsync(request); + + Console.WriteLine(result); + return 0; +} + +public class ScalarRequest : IScalarRequest +{ + public string Value { get; set; } = string.Empty; +} + +public class ScalarHandler : IScalarRequestHandler +{ + public Task HandleAsync(ScalarTestRequest request, CancellationToken cancellationToken) + { + return Task.FromResult($"{request.Value} World"); + } +} + +public class ScalarBehavior : IScalarRequestBehavior +{ + public async Task HandleAsync(ScalarTestRequest request, ScalarHandlerDelegate next, CancellationToken cancellationToken) + { + Console.WriteLine("Before"); + var result = await next(request, cancellationToken); + Console.WriteLine("After"); + return result; + } +} +``` + +## Behaviour of the Handlers + +Handlers are resolved from either the DI conatiner or are created on the fly but can receive arguments from the DI +container when being constructed. The same also applied for the request pipeline behaviours. diff --git a/src/Request/package-readme.md b/src/Request/package-readme.md index e69de29..a003a51 100644 --- a/src/Request/package-readme.md +++ b/src/Request/package-readme.md @@ -0,0 +1,65 @@ +Simple mediator implementation in .NET with minimal dependencies. + +## Features + +- **Simple interfaces:** no complex constraints, just marker interfaces that work. +- **Minmal dependencies:** only depends on `Microsoft.Extensions.DependencyInjection.Abstractions` and the + `Microsoft.Extensions.Options` package. + +## Getting Started + +### Install the NuGet package: + +```shell +dotnet add package Geekeey.Request +``` + +You may need to add our NuGet feed to your `nuget.config` this can be done by running the following command: + +```shell +dotnet nuget add source -n geekeey https://code.geekeey.de/api/packages/geekeey/nuget/index.json +``` + +### Usage + +```csharp +public static Task Main() +{ + var collection = new ServiceCollection(); + collection.AddRequestDispatcher(builder => builder + .Add(typeof(ScalarHandler)) + .Add(typeof(ScalarBehavior))); + await using var provider = collection.BuildServiceProvider(); + var dispatcher = provider.GetRequiredService(); + + var request = new ScalarRequest { Value = "Hello" }; + var result = await dispatcher.DispatchAsync(request); + + Console.WriteLine(result); + return 0; +} + +public class ScalarRequest : IScalarRequest +{ + public string Value { get; set; } = string.Empty; +} + +public class ScalarHandler : IScalarRequestHandler +{ + public Task HandleAsync(ScalarTestRequest request, CancellationToken cancellationToken) + { + return Task.FromResult($"{request.Value} World"); + } +} + +public class ScalarBehavior : IScalarRequestBehavior +{ + public async Task HandleAsync(ScalarTestRequest request, ScalarHandlerDelegate next, CancellationToken cancellationToken) + { + Console.WriteLine("Before"); + var result = await next(request, cancellationToken); + Console.WriteLine("After"); + return result; + } +} +```