Browse Source

fixed .net core 2.0 services resolve bug

master
Savorboard 7 years ago
parent
commit
756935abfb
1 changed files with 14 additions and 10 deletions
  1. +14
    -10
      src/DotNetCore.CAP/Internal/IConsumerServiceSelector.Default.cs

+ 14
- 10
src/DotNetCore.CAP/Internal/IConsumerServiceSelector.Default.cs View File

@@ -48,19 +48,23 @@ namespace DotNetCore.CAP.Internal
IServiceProvider provider)
{
var executorDescriptorList = new List<ConsumerExecutorDescriptor>();

var consumerServices = provider.GetServices<ICapSubscribe>();
foreach (var service in consumerServices)
using (var scoped = provider.CreateScope())
{
var typeInfo = service.GetType().GetTypeInfo();
if (!typeof(ICapSubscribe).GetTypeInfo().IsAssignableFrom(typeInfo))
var scopedProvider = scoped.ServiceProvider;
var consumerServices = scopedProvider.GetServices<ICapSubscribe>();
foreach (var service in consumerServices)
{
continue;
}
var typeInfo = service.GetType().GetTypeInfo();
if (!typeof(ICapSubscribe).GetTypeInfo().IsAssignableFrom(typeInfo))
{
continue;
}

executorDescriptorList.AddRange(GetTopicAttributesDescription(typeInfo));
executorDescriptorList.AddRange(GetTopicAttributesDescription(typeInfo));
}
return executorDescriptorList;
}
return executorDescriptorList;
}

private static IEnumerable<ConsumerExecutorDescriptor> FindConsumersFromControllerTypes(
@@ -76,7 +80,7 @@ namespace DotNetCore.CAP.Internal
{
executorDescriptorList.AddRange(GetTopicAttributesDescription(typeInfo));
}
}
}

return executorDescriptorList;
}


Loading…
Cancel
Save