All Projects → BrighterCommand → Darker

BrighterCommand / Darker

Licence: mit
The query-side counterpart of Brighter

Projects that are alternatives of or similar to Darker

Pmcenter
A Telegram bot helping you process private messages.
Stars: ✭ 115 (-7.26%)
Mutual labels:  dotnet-core
Easy.logger
A modern, high performance cross platform wrapper for Log4Net.
Stars: ✭ 118 (-4.84%)
Mutual labels:  dotnet-core
Recaptcha.aspnetcore
Google reCAPTCHA v2/v3 for .NET Core 3.x
Stars: ✭ 122 (-1.61%)
Mutual labels:  dotnet-core
Settings.net
⚙️ Settings.Net - An easy to use .NET library for accessing and storing settings and configurations.
Stars: ✭ 114 (-8.06%)
Mutual labels:  dotnet-core
Fanray
A blog built with ASP.NET Core
Stars: ✭ 117 (-5.65%)
Mutual labels:  dotnet-core
Plotly.net
.NET interface for plotly.js written in F# 📈
Stars: ✭ 119 (-4.03%)
Mutual labels:  dotnet-core
Reinforced.tecture
Aspect-based architectural framework for .NET business applications involving some FP and CQRS principles.
Stars: ✭ 113 (-8.87%)
Mutual labels:  dotnet-core
Cv4pve Autosnap
Automatic snapshot tool for Proxmox VE
Stars: ✭ 123 (-0.81%)
Mutual labels:  dotnet-core
Kafka Flow
KafkaFlow is a .NET framework to consume and produce Kafka messages with multi-threading support. It's very simple to use and very extendable. You just need to install, configure, start/stop the bus with your app and create a middleware/handler to process the messages.
Stars: ✭ 118 (-4.84%)
Mutual labels:  dotnet-core
Sio.core
✔ [ SIOC ] Swastika I/O Core is an all in one platform (e.g CMS, eCommerce, Forum, Q&A, CRM...) ASP.NET Core / Dotnet Core System based on SIOH Framework.
Stars: ✭ 121 (-2.42%)
Mutual labels:  dotnet-core
Dotnet Tools
A list of tools to extend the .NET Core command line (dotnet)
Stars: ✭ 1,551 (+1150.81%)
Mutual labels:  dotnet-core
Radish
Desktop client for Redis (Windows, MacOS, Linux)
Stars: ✭ 117 (-5.65%)
Mutual labels:  dotnet-core
Csharp Datatables Parser
C# Serverside parser for the popuplar jQuery datatables plugin.
Stars: ✭ 119 (-4.03%)
Mutual labels:  dotnet-core
Ngenerics
Data structures and algorithms for .NET
Stars: ✭ 115 (-7.26%)
Mutual labels:  dotnet-core
Reactivetradercloud
Real-time FX trading showcase by Adaptive.
Stars: ✭ 1,664 (+1241.94%)
Mutual labels:  dotnet-core
Puck Core
Open source, cross platform .NET Core CMS. Fast, scalable, code-first, unobtrusive and extensible with powerful querying and Lucene integration.
Stars: ✭ 115 (-7.26%)
Mutual labels:  dotnet-core
Nsubstitute
A friendly substitute for .NET mocking libraries.
Stars: ✭ 1,646 (+1227.42%)
Mutual labels:  dotnet-core
Colore
A powerful C# library for Razer Chroma's SDK
Stars: ✭ 121 (-2.42%)
Mutual labels:  dotnet-core
Xunit.gherkin.quick
BDD in .NET Core - using Xunit and Gherkin (compatible with both .NET Core and .NET)
Stars: ✭ 123 (-0.81%)
Mutual labels:  dotnet-core
Samples
Sample code referenced by the .NET documentation
Stars: ✭ 1,875 (+1412.1%)
Mutual labels:  dotnet-core

Darker

The query-side counterpart of Brighter.

.NET Core NuGet

Usage with ASP.NET Core

In your ConfigureServices method, use AddDarker to add Darker to the container. ASP.NET Core integration is provided by the Paramore.Darker.AspNetCore package.

// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
    // Add Darker and some extensions.
    services.AddDarker()
        .AddHandlersFromAssemblies(typeof(GetPeopleQueryHandler).Assembly)
        .AddJsonQueryLogging()
        .AddDefaultPolicies();

    // Add framework services.
    services.AddMvc();
}

WARNING if you are using EFCore the DBContext DI Lifetime is scoped, for Darker to play nicely with EFCore and DI the QueryProcessor must also be registration as Scoped

 services.AddDarker(options =>
                {
                    //EFCore by default registers Context as scoped, which forces the QueryProcessorLifetime to also be scoped
                    options.QueryProcessorLifetime = ServiceLifetime.Scoped;
                })

This example uses the request logging integration provided by Paramore.Darker.QueryLogging and policy integration provided by Paramore.Darker.Policies. Have a look at the Startup.ConfigureServices method in the SampleApi project for more examples on how to use the integrations.

Inject IQueryProcessor and call Execute or ExecuteAsync to dispatch your query to the registered query handler.

using Paramore.Darker;
using Microsoft.AspNetCore.Mvc;
using System.Threading;
using System.Threading.Tasks;

public class FooController : ControllerBase
{
    private readonly IQueryProcessor _queryProcessor;

    public FooController(IQueryProcessor queryProcessor)
    {
        _queryProcessor = queryProcessor;
    }

    public async Task<IActionResult> Get(CancellationToken cancellationToken = default(CancellationToken))
    {
        var query = new GetFoo(42);
        var result = await _queryProcessor.ExecuteAsync(query, cancellationToken);
        return Ok(result);
    }
}
using Paramore.Darker;

public sealed class GetFoo : IQuery<string>
{
    public int Number { get; }

    public GetFoo(int number)
    {
        Number = number;
    }
}

Implement either QueryHandler<,> or QueryHandlerAsync<,> depending on whether you wish to execute your queries synchronously or asynchronously. For most control, you can also implement IQueryHandler<,> directly.

using Paramore.Darker;
using Paramore.Darker.Attributes;
using Paramore.Darker.Policies;
using Paramore.Darker.QueryLogging;
using System.Threading;
using System.Threading.Tasks;

public sealed class GetFooHandler : QueryHandlerAsync<GetFoo, string>
{
    [QueryLogging(1)]
    [FallbackPolicy(2)]
    [RetryableQuery(3)]
    public override async Task<string> ExecuteAsync(GetFoo query, CancellationToken cancellationToken = default(CancellationToken))
    {
        return await FetchFooForNumber(query.Number, cancellationToken);
    }
}

Usage without ASP.NET

Register your queries and handlers with QueryHandlerRegistry and use QueryProcessorBuilder to configure and build a IQueryProcessor.

var registry = new QueryHandlerRegistry();
registry.Register<GetFoo, string, GetFooHandler>();

IQueryProcessor queryProcessor = QueryProcessorBuilder.With()
    .Handlers(registry, Activator.CreateInstance, t => {}, Activator.CreateInstance)
    .InMemoryQueryContextFactory()
    .Build();

Instead of Activator.CreateInstance, you can pass any factory Func<Type, object> to constuct handlers and decorator. Integrations with some DI frameworks are available, for example SimpleInjector, as provided by the Paramore.Darker.SimpleInjector package:

var container = new Container();

var queryProcessor = QueryProcessorBuilder.With()
    .SimpleInjectoHandlers(container, opts =>
        opts.WithQueriesAndHandlersFromAssembly(typeof(GetPeopleQuery).Assembly))
    .InMemoryQueryContextFactory()
    .Build();

container.Register<IQueryProcessor>(queryProcessor);

In this case you don't need to manually register queries or handlers as the integration allows scanning assemblies for matching types.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].