Skip to content

Commit

Permalink
Add UnitOfWorkManager to DI container
Browse files Browse the repository at this point in the history
  • Loading branch information
KonstantinRyazantsev committed Aug 12, 2020
1 parent e0efc1a commit de5e6f8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

namespace Swisschain.Extensions.Idempotency
{
public sealed class IdempotencyConfigurationBuilder
public sealed class IdempotencyConfigurationBuilder<TUnitOfWork>
where TUnitOfWork : UnitOfWorkBase
{
internal IdempotencyConfigurationBuilder(IServiceCollection services)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@ namespace Swisschain.Extensions.Idempotency
{
public static class IdempotencyServiceCollectionExtensions
{
/// <summary>
///
/// </summary>
public static IServiceCollection AddIdempotency(this IServiceCollection services, Action<IdempotencyConfigurationBuilder> config)
public static IServiceCollection AddIdempotency<TUnitOfWork>(this IServiceCollection services, Action<IdempotencyConfigurationBuilder<TUnitOfWork>> config)
where TUnitOfWork : UnitOfWorkBase
{
services.AddTransient<IUnitOfWorkManager<TUnitOfWork>, UnitOfWorkManager<TUnitOfWork>>();

services.AddTransient<IOutboxManager, OutboxManager>();
services.AddTransient<IIdGenerator, IdGenerator>();

services.AddTransient<IOutboxDispatcher, DefaultOutboxDispatcher>();

services.AddTransient<IOutboxReadRepository, DefaultOutboxReadRepository>();
services.AddTransient<IIdGeneratorRepository, DefaultIdGeneratorRepository>();

if (config != null)
{
var configBuilder = new IdempotencyConfigurationBuilder(services);
var configBuilder = new IdempotencyConfigurationBuilder<TUnitOfWork>(services);

config.Invoke(configBuilder);
}
Expand Down

0 comments on commit de5e6f8

Please sign in to comment.