public static IZaabyServer UseDomainEventHandler(this IZaabyServer zaabyServer) { var domainEventSubscriberTypes = AllTypes .Where(type => type.IsClass && typeof(IDomainEventHandler).IsAssignableFrom(type)).ToList(); domainEventSubscriberTypes.ForEach(domainEventSubscriberType => zaabyServer.AddScoped(domainEventSubscriberType)); zaabyServer.AddScoped(typeof(IDomainEventPublisher), typeof(DomainEventPublisher)); zaabyServer.AddSingleton <DomainEventHandlerProvider>(); return(zaabyServer); }
public static IZaabyServer UseDomainEventHandler(this IZaabyServer zaabyServer, Func <Type, bool> domainEventHandlerDefinition) { var domainEventSubscriberTypes = AllTypes .Where(domainEventHandlerDefinition).ToList(); domainEventSubscriberTypes.ForEach(domainEventSubscriberType => zaabyServer.AddScoped(domainEventSubscriberType)); zaabyServer.AddScoped(typeof(IDomainEventPublisher), typeof(DomainEventPublisher)); zaabyServer.AddSingleton <DomainEventHandlerProvider>(); return(zaabyServer); }
public static IZaabyServer UseEventBus(this IZaabyServer zaabyServer) { AllTypes = zaabyServer.AllTypes; var interfaceType = typeof(IIntegrationEventBus); var eventBusType = AllTypes.FirstOrDefault(type => interfaceType.IsAssignableFrom(type) && type.IsClass); if (eventBusType == null) { return(zaabyServer); } zaabyServer.AddSingleton(interfaceType, eventBusType); zaabyServer.RegisterServiceRunner(interfaceType, eventBusType); return(zaabyServer); }
public static IZaabyServer UseDomainEventHandler(this IZaabyServer zaabyServer) { var domainEventHandlerQuery = AllTypes.Where(type => type.IsClass); domainEventHandlerQuery = domainEventHandlerQuery.Where(type => type.BaseType != null && type.BaseType.IsGenericType && type.BaseType.GetGenericTypeDefinition() == typeof(DomainEventHandler <>)); var domainEventHandlers = domainEventHandlerQuery.ToList(); domainEventHandlers.ForEach(domainEventHandler => { zaabyServer.AddSingleton(domainEventHandler, domainEventHandler); zaabyServer.RegisterServiceRunner(domainEventHandler); }); return(zaabyServer); }