Przeglądaj źródła

move controller services finder to DefaultConsumerServiceSelector

master
Savorboard 7 lat temu
rodzic
commit
a8ba769a2f
2 zmienionych plików z 9 dodań i 19 usunięć
  1. +0
    -9
      src/DotNetCore.CAP/CAP.ServiceCollectionExtensions.cs
  2. +9
    -10
      src/DotNetCore.CAP/Internal/IConsumerServiceSelector.Default.cs

+ 0
- 9
src/DotNetCore.CAP/CAP.ServiceCollectionExtensions.cs Wyświetl plik

@@ -82,15 +82,6 @@ namespace Microsoft.Extensions.DependencyInjection
{
services.AddTransient(service.Key, service.Value);
}

var types = Assembly.GetEntryAssembly().ExportedTypes;
foreach (var type in types)
{
if (Helper.IsController(type.GetTypeInfo()))
{
services.AddTransient(typeof(object), type);
}
}
}
}
}

+ 9
- 10
src/DotNetCore.CAP/Internal/IConsumerServiceSelector.Default.cs Wyświetl plik

@@ -67,17 +67,16 @@ namespace DotNetCore.CAP.Internal
IServiceProvider provider)
{
var executorDescriptorList = new List<ConsumerExecutorDescriptor>();
// at cap startup time, find all Controller into the DI container,the type is object.
var controllers = provider.GetServices<object>();
foreach (var controller in controllers)
{
var typeInfo = controller.GetType().GetTypeInfo();

//double check
if (!Helper.IsController(typeInfo)) continue;

executorDescriptorList.AddRange(GetTopicAttributesDescription(typeInfo));
}
var types = Assembly.GetEntryAssembly().ExportedTypes;
foreach (var type in types)
{
var typeInfo = type.GetTypeInfo();
if (Helper.IsController(typeInfo))
{
executorDescriptorList.AddRange(GetTopicAttributesDescription(typeInfo));
}
}

return executorDescriptorList;
}


Ładowanie…
Anuluj
Zapisz