Browse Source

fixed consumer method add to DI exception. (#38)

master
Savorboard 7 years ago
parent
commit
9473d245a0
1 changed files with 5 additions and 3 deletions
  1. +5
    -3
      src/DotNetCore.CAP/CAP.ServiceCollectionExtensions.cs

+ 5
- 3
src/DotNetCore.CAP/CAP.ServiceCollectionExtensions.cs View File

@@ -67,13 +67,15 @@ namespace Microsoft.Extensions.DependencyInjection


private static void AddSubscribeServices(IServiceCollection services) private static void AddSubscribeServices(IServiceCollection services)
{ {
var consumerListenerServices = new Dictionary<Type, Type>();
var consumerListenerServices = new List<KeyValuePair<Type, Type>>();
foreach (var rejectedServices in services) foreach (var rejectedServices in services)
{ {
if (rejectedServices.ImplementationType != null if (rejectedServices.ImplementationType != null
&& typeof(ICapSubscribe).IsAssignableFrom(rejectedServices.ImplementationType)) && typeof(ICapSubscribe).IsAssignableFrom(rejectedServices.ImplementationType))

consumerListenerServices.Add(typeof(ICapSubscribe), rejectedServices.ImplementationType);
{
consumerListenerServices.Add(new KeyValuePair<Type, Type>(typeof(ICapSubscribe),
rejectedServices.ImplementationType));
}
} }


foreach (var service in consumerListenerServices) foreach (var service in consumerListenerServices)


Loading…
Cancel
Save