37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
#nullable enable
|
|
|
|
using System;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
|
using Svrnty.CQRS.Abstractions.Discovery;
|
|
using Svrnty.CQRS.Configuration;
|
|
using Svrnty.CQRS.Discovery;
|
|
|
|
namespace Svrnty.CQRS;
|
|
|
|
public static class ServiceCollectionExtensions
|
|
{
|
|
/// <summary>
|
|
/// Adds Svrnty CQRS services with fluent configuration
|
|
/// </summary>
|
|
public static IServiceCollection AddSvrntyCqrs(this IServiceCollection services, Action<CqrsBuilder>? configure = null)
|
|
{
|
|
var builder = new CqrsBuilder(services);
|
|
configure?.Invoke(builder);
|
|
builder.Build(); // Execute deferred registrations
|
|
return services;
|
|
}
|
|
|
|
public static IServiceCollection AddDefaultQueryDiscovery(this IServiceCollection services)
|
|
{
|
|
services.TryAddTransient<IQueryDiscovery, QueryDiscovery>();
|
|
return services;
|
|
}
|
|
|
|
public static IServiceCollection AddDefaultCommandDiscovery(this IServiceCollection services)
|
|
{
|
|
services.TryAddTransient<ICommandDiscovery, CommandDiscovery>();
|
|
return services;
|
|
}
|
|
}
|