@@ -11,10 +11,9 @@ namespace DotNetCore.CAP.Abstractions | |||||
/// <summary> | /// <summary> | ||||
/// Selects a set of <see cref="ConsumerExecutorDescriptor"/> candidates for the current message associated with | /// Selects a set of <see cref="ConsumerExecutorDescriptor"/> candidates for the current message associated with | ||||
/// <paramref name="provider"/>. | /// <paramref name="provider"/>. | ||||
/// </summary> | |||||
/// <param name="provider"> <see cref="IServiceProvider"/>.</param> | |||||
/// </summary> | |||||
/// <returns>A set of <see cref="ConsumerExecutorDescriptor"/> candidates or <c>null</c>.</returns> | /// <returns>A set of <see cref="ConsumerExecutorDescriptor"/> candidates or <c>null</c>.</returns> | ||||
IReadOnlyList<ConsumerExecutorDescriptor> SelectCandidates(IServiceProvider provider); | |||||
IReadOnlyList<ConsumerExecutorDescriptor> SelectCandidates(); | |||||
/// <summary> | /// <summary> | ||||
/// Selects the best <see cref="ConsumerExecutorDescriptor"/> candidate from <paramref name="candidates"/> for the | /// Selects the best <see cref="ConsumerExecutorDescriptor"/> candidate from <paramref name="candidates"/> for the | ||||
@@ -47,7 +47,7 @@ namespace DotNetCore.CAP | |||||
public void Start() | public void Start() | ||||
{ | { | ||||
var groupingMatchs = _selector.GetCandidatesMethodsOfGroupNameGrouped(_serviceProvider); | |||||
var groupingMatchs = _selector.GetCandidatesMethodsOfGroupNameGrouped(); | |||||
foreach (var matchGroup in groupingMatchs) | foreach (var matchGroup in groupingMatchs) | ||||
{ | { | ||||
@@ -33,13 +33,13 @@ namespace DotNetCore.CAP.Internal | |||||
return executeDescriptor.FirstOrDefault(x => x.Attribute.Name == key); | return executeDescriptor.FirstOrDefault(x => x.Attribute.Name == key); | ||||
} | } | ||||
public IReadOnlyList<ConsumerExecutorDescriptor> SelectCandidates(IServiceProvider provider) | |||||
public IReadOnlyList<ConsumerExecutorDescriptor> SelectCandidates() | |||||
{ | { | ||||
var executorDescriptorList = new List<ConsumerExecutorDescriptor>(); | var executorDescriptorList = new List<ConsumerExecutorDescriptor>(); | ||||
executorDescriptorList.AddRange(FindConsumersFromInterfaceTypes(provider)); | |||||
executorDescriptorList.AddRange(FindConsumersFromInterfaceTypes(_serviceProvider)); | |||||
executorDescriptorList.AddRange(FindConsumersFromControllerTypes(provider)); | |||||
executorDescriptorList.AddRange(FindConsumersFromControllerTypes(_serviceProvider)); | |||||
return executorDescriptorList; | return executorDescriptorList; | ||||
} | } | ||||
@@ -22,12 +22,11 @@ namespace DotNetCore.CAP.Internal | |||||
/// Get a dictionary of candidates.In the dictionary, | /// Get a dictionary of candidates.In the dictionary, | ||||
/// the Key is the CAPSubscribeAttribute Group, the Value for the current Group of candidates | /// the Key is the CAPSubscribeAttribute Group, the Value for the current Group of candidates | ||||
/// </summary> | /// </summary> | ||||
/// <param name="provider"><see cref="IServiceProvider"/></param> | |||||
public ConcurrentDictionary<string, IList<ConsumerExecutorDescriptor>> GetCandidatesMethodsOfGroupNameGrouped(IServiceProvider provider) | |||||
public ConcurrentDictionary<string, IList<ConsumerExecutorDescriptor>> GetCandidatesMethodsOfGroupNameGrouped() | |||||
{ | { | ||||
if (Entries.Count != 0) return Entries; | if (Entries.Count != 0) return Entries; | ||||
var executorCollection = _selector.SelectCandidates(provider); | |||||
var executorCollection = _selector.SelectCandidates(); | |||||
var groupedCandidates = executorCollection.GroupBy(x => x.Attribute.Group); | var groupedCandidates = executorCollection.GroupBy(x => x.Attribute.Group); | ||||
@@ -25,7 +25,7 @@ namespace DotNetCore.CAP.Test | |||||
public void CanFindAllConsumerService() | public void CanFindAllConsumerService() | ||||
{ | { | ||||
var selector = _provider.GetRequiredService<IConsumerServiceSelector>(); | var selector = _provider.GetRequiredService<IConsumerServiceSelector>(); | ||||
var candidates = selector.SelectCandidates(_provider); | |||||
var candidates = selector.SelectCandidates(); | |||||
Assert.Equal(2, candidates.Count); | Assert.Equal(2, candidates.Count); | ||||
} | } | ||||
@@ -34,7 +34,7 @@ namespace DotNetCore.CAP.Test | |||||
public void CanFindSpecifiedTopic() | public void CanFindSpecifiedTopic() | ||||
{ | { | ||||
var selector = _provider.GetRequiredService<IConsumerServiceSelector>(); | var selector = _provider.GetRequiredService<IConsumerServiceSelector>(); | ||||
var candidates = selector.SelectCandidates(_provider); | |||||
var candidates = selector.SelectCandidates(); | |||||
var bestCandidates = selector.SelectBestCandidate("Candidates.Foo", candidates); | var bestCandidates = selector.SelectBestCandidate("Candidates.Foo", candidates); | ||||
Assert.NotNull(bestCandidates); | Assert.NotNull(bestCandidates); | ||||