/// <summary> /// Registers the given message handler type /// </summary> public void RegisterHandler(Type handlerType) { if (handlerType.IsAbstract) { return; } var messageTypesThisHandlerHandles = GetMessageTypesIfIsMessageHandler(handlerType).ToList(); foreach (var messageType in messageTypesThisHandlerHandles) { if (!handlerList.ContainsKey(handlerType)) { handlerList.Add(handlerType, new List <Type>()); } if (!(handlerList[handlerType].Contains(messageType))) { handlerList[handlerType].Add(messageType); Log.DebugFormat("Associated '{0}' message with '{1}' handler", messageType, handlerType); } HandlerInvocationCache.CacheMethodForHandler(handlerType, messageType); } }
public IEnumerable <Action> GetDispatcher(Type messageHandlerType, IBuilder builder, object toHandle) { yield return(() => builder.BuildAndDispatch(messageHandlerType, handler => HandlerInvocationCache.Invoke(typeof(IMessageHandler <>), handler, toHandle))); }