From 8e7f9aa836685768b68accf41571d3e1267c4076 Mon Sep 17 00:00:00 2001 From: maliming Date: Fri, 12 May 2023 08:34:36 +0800 Subject: [PATCH] Update LocalEventBus.cs --- .../Volo/Abp/EventBus/Local/LocalEventBus.cs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Local/LocalEventBus.cs b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Local/LocalEventBus.cs index e1edf3b12f..d73b2f8de9 100644 --- a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Local/LocalEventBus.cs +++ b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Local/LocalEventBus.cs @@ -139,26 +139,19 @@ public class LocalEventBus : EventBusBase, ILocalEventBus, ISingletonDependency protected override IEnumerable GetHandlerFactories(Type eventType) { - var handlerFactoryList = new List(); - - var handlerWithTypes = new List>(); + var handlerFactoryList = new List>(); foreach (var handlerFactory in HandlerFactories.Where(hf => ShouldTriggerEventForHandler(eventType, hf.Key))) { foreach (var factory in handlerFactory.Value) { - handlerWithTypes.Add(new Tuple( + handlerFactoryList.Add(new Tuple( factory, handlerFactory.Key, ReflectionHelper.GetAttributesOfMemberOrDeclaringType(factory.GetHandler().EventHandler.GetType()).FirstOrDefault()?.Order ?? 0)); } } - foreach (var handlerWithType in handlerWithTypes.OrderBy(x => x.Item3)) - { - handlerFactoryList.Add(new EventTypeWithEventHandlerFactories(handlerWithType.Item2, new List{ handlerWithType.Item1 })); - } - - return handlerFactoryList.ToArray(); + return handlerFactoryList.OrderBy(x => x.Item3).Select(x => new EventTypeWithEventHandlerFactories(x.Item2, new List {x.Item1})).ToArray(); } private List GetOrCreateHandlerFactories(Type eventType)