/// <summary> /// /// </summary> /// <param name="handlerType"></param> /// <param name="activationType"></param> /// <returns></returns> public static EventHandlerDescriptor Describe(Type handlerType, EventHandlerActivationType activationType) { if (!handlerType.IsAssignableTo <IEventHandler>()) { throw new ArgumentException($"{nameof(handlerType)} should be derived from {typeof(IEventHandler)}", nameof(handlerType)); } return(new EventHandlerDescriptor(handlerType, activationType)); }
/// <summary> /// /// </summary> /// <param name="options"></param> /// <param name="activationType"></param> /// <typeparam name="TEventHandler"></typeparam> /// <returns></returns> public static EventBusOptions AddHandler <TEventHandler>(this EventBusOptions options, EventHandlerActivationType activationType) where TEventHandler : class, IEventHandler { options.AddHandler(EventHandlerDescriptor.Describe <TEventHandler>(activationType)); return(options); }
/// <summary> /// /// </summary> /// <param name="options"></param> /// <param name="handlerType"></param> /// <param name="activationType"></param> /// <returns></returns> public static EventBusOptions AddHandler(this EventBusOptions options, Type handlerType, EventHandlerActivationType activationType) { options.AddHandler(EventHandlerDescriptor.Describe(handlerType, activationType)); return(options); }
public ActivationTypeSelector(EventHandlerActivationType activationType) { _activationType = activationType; }
/// <summary> /// /// </summary> /// <typeparam name="TEventHandler"></typeparam> /// <param name="activationType"></param> /// <returns></returns> public static EventHandlerDescriptor Describe <TEventHandler>(EventHandlerActivationType activationType) where TEventHandler : class, IEventHandler { return(Describe(typeof(TEventHandler), activationType)); }
/// <summary> /// /// </summary> /// <param name="activationType"></param> /// <param name="handlerType"></param> public EventHandlerDescriptor(Type handlerType, EventHandlerActivationType activationType) { ActivationType = activationType; HandlerType = handlerType; }
/// <summary> /// /// </summary> /// <param name="context"></param> /// <param name="activationType"></param> /// <returns></returns> public static IConventionalContext ActivationByType(this IConventionalContext context, EventHandlerActivationType activationType) { context.Set("HandlerActivationTypeSelector", new ActivationTypeSelector(activationType)); return(context); }