GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - feature23/kernel

BranchesTags
Open more actions menu

Latest commit

 

History

26 Commits
26 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
src
src
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 

Repository files navigation

feature[23] Shared Kernel

build

A library of reusable types for implementing Clean Architecture in .NET and ASP.NET Core applications, based heavily on the work of Steve Smith in the following open-source projects:

  • ASP.NET Core Template
  • Shared Kernel

For the core functionality, only the F23.Kernel library is needed. This library provides types for events, results, query and command handlers, validation, and messaging. For smoother integration with ASP.NET Core, the F23.Kernel.AspNetCore library can be used for easily mapping between core result types and ASP.NET Core IActionResult and model state.

WARNING: This library is currently in a pre-release state, and breaking changes may occur before reaching version 1.0.


What if your day job was contributing to open-source projects and custom AI solutions — and you got paid for it?
We're hiring remote engineers to contribute to cutting-edge AI and custom software projects. 100% remote, 100% real impact. https://www.feature23.com/careers

NuGet Installation

Core Package

dotnet add package F23.Kernel

ASP.NET Core Helper Package

dotnet add package F23.Kernel.AspNetCore

Examples

Query Handler

class GetWeatherForecastQueryResult
{
    public required IReadOnlyList<WeatherForecast> Forecast { get; init; }
}

class GetWeatherForecastQuery : IQuery<GetWeatherForecastQueryResult>
{
    public int DaysIntoTheFuture { get; init; } = 5;
}

record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
{
    public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}

class GetWeatherForecastQueryHandler(IValidator<GetWeatherForecastQuery> validator, IWeatherForecastRepository repository)
    : IQueryHandler<GetWeatherForecastQuery, GetWeatherForecastQueryResult>
{
    public async Task<Result<GetWeatherForecastQueryResult>> Handle(GetWeatherForecastQuery query, CancellationToken cancellationToken = default)
    {
        if (await validator.Validate(query, cancellationToken) is ValidationFailedResult failed)
        {
            return Result<GetWeatherForecastQueryResult>.ValidationFailed(failed.Errors);
        }

        var forecast = await repository.GetForecast(query.DaysIntoTheFuture, cancellationToken);

        var result = new GetWeatherForecastQueryResult
        {
            Forecast = forecast
        };

        return Result<GetWeatherForecastQueryResult>.Success(result);
    }
}

Program.cs

builder.Services.RegisterQueryHandler<GetWeatherForecastQuery, GetWeatherForecastQueryResult, GetWeatherForecastQueryHandler>();

// Other code omitted for brevity

app.MapGet("/weatherforecast", async (IQueryHandler<GetWeatherForecastQuery, GetWeatherForecastQueryResult> queryHandler) =>
    {
        var result = await queryHandler.Handle(new GetWeatherForecastQuery());

        return result.ToMinimalApiResult();
    })
    .WithName("GetWeatherForecast")
    .WithOpenApi();

Command Handler

TODO

Event Sourcing

TODO

About

No description, website, or topics provided.

Resources

Readme
MIT license
Activity
Custom properties

Stars

1 star

Watchers

4 watching

Forks

2 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.