Преглед изворни кода

fixed .net core 2.0 services resolve bug

master
Savorboard пре 7 година
родитељ
комит
756935abfb
1 измењених фајлова са 14 додато и 10 уклоњено
  1. +14
    -10
      src/DotNetCore.CAP/Internal/IConsumerServiceSelector.Default.cs

+ 14
- 10
src/DotNetCore.CAP/Internal/IConsumerServiceSelector.Default.cs Прегледај датотеку

@@ -48,19 +48,23 @@ namespace DotNetCore.CAP.Internal
IServiceProvider provider) IServiceProvider provider)
{ {
var executorDescriptorList = new List<ConsumerExecutorDescriptor>(); 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( private static IEnumerable<ConsumerExecutorDescriptor> FindConsumersFromControllerTypes(
@@ -76,7 +80,7 @@ namespace DotNetCore.CAP.Internal
{ {
executorDescriptorList.AddRange(GetTopicAttributesDescription(typeInfo)); executorDescriptorList.AddRange(GetTopicAttributesDescription(typeInfo));
} }
}
}


return executorDescriptorList; return executorDescriptorList;
} }


Loading…
Откажи
Сачувај