Browse Source

fixed consumer method injection context bug. (#34)

master
yangxiaodong 7 years ago
parent
commit
8c5da12d83
1 changed files with 8 additions and 4 deletions
  1. +8
    -4
      src/DotNetCore.CAP/Internal/ConsumerInvokerFactory.cs

+ 8
- 4
src/DotNetCore.CAP/Internal/ConsumerInvokerFactory.cs View File

@@ -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;
}
}
}
}

Loading…
Cancel
Save