Ver código fonte

fixed consumer method injection context bug. (#34)

master
yangxiaodong 7 anos atrás
pai
commit
8c5da12d83
1 arquivos alterados com 8 adições e 4 exclusões
  1. +8
    -4
      src/DotNetCore.CAP/Internal/ConsumerInvokerFactory.cs

+ 8
- 4
src/DotNetCore.CAP/Internal/ConsumerInvokerFactory.cs Ver arquivo

@@ -1,5 +1,6 @@
using System;
using DotNetCore.CAP.Abstractions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

namespace DotNetCore.CAP.Internal
@@ -22,12 +23,15 @@ namespace DotNetCore.CAP.Internal

public IConsumerInvoker CreateInvoker(ConsumerContext consumerContext)
{
var context = new ConsumerInvokerContext(consumerContext)
using(var scope = _serviceProvider.CreateScope())
{
Result = new DefaultConsumerInvoker(_logger, _serviceProvider, _modelBinderFactory, consumerContext)
};
var context = new ConsumerInvokerContext(consumerContext)
{
Result = new DefaultConsumerInvoker(_logger, scope.ServiceProvider, _modelBinderFactory, consumerContext)
};

return context.Result;
return context.Result;
}
}
}
}

Carregando…
Cancelar
Salvar