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)