Exemple #1
0
 public DomainEventStore(DomainEventStoreOptions options, IDomainEventDispatcher domainEventDispatcher, IBackgroundJobManager jobManager)
 {
     _options = options;
     _domainEventDispatcher = domainEventDispatcher;
     _jobManager            = jobManager;
 }
        public static IServiceCollection AddDomainEvents(this IServiceCollection services, IConfiguration configuration, DomainEventStoreOptions options = default)
        {
            // register our Implementation of the domainEventStore
            services.AddSingleton <IDomainEventDispatcher, DomainEventDispatcher>();
            services.AddSingleton <IDomainEventStore, DomainEventStore>();
            services.AddOptions();
            services.Configure <DomainEventStoreOptions>(configuration.GetSection("qq"));
            //services.ConfigureOptions(options ?? new DomainEventStoreOptions());
            // register all types of IDomainEventHandler
            var domainEventHandlerTypes = ReflectionHelper.GetAllConcreteTypesImplementingGenericInterface(typeof(IDomainEventHandler <>));

            foreach (var(handlerType, domainEventType) in domainEventHandlerTypes)
            {
                services.AddScoped(typeof(IDomainEventHandler <>).MakeGenericType(domainEventType), handlerType);
            }
            return(services);
        }