Ejemplo n.º 1
0
        public static IServiceCollection AddEventStoreBusHandler(this IServiceCollection services, IEnumerable <Type> handlers = null)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            services.AddTransient <GroupHandler>();
            services.AddTransient <ScimErrorHandler>();
            services.AddTransient <UserHandler>();
            var provider        = services.BuildServiceProvider();
            var evtHandlerStore = new EvtHandlerStore(provider);

            evtHandlerStore.Register(typeof(GroupHandler));
            evtHandlerStore.Register(typeof(ScimErrorHandler));
            evtHandlerStore.Register(typeof(UserHandler));
            if (handlers != null)
            {
                foreach (var handler in handlers)
                {
                    evtHandlerStore.Register(handler);
                }
            }

            services.AddSingleton(typeof(IEvtHandlerStore), evtHandlerStore);
            return(services);
        }
Ejemplo n.º 2
0
        public static IServiceCollection AddDefaultBus(this IServiceCollection services, IEnumerable <Type> handlers = null)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            services.AddTransient <IPayloadSerializer, PayloadSerializer>();
            services.AddTransient <AuthorizationHandler>();
            services.AddTransient <OpenIdErrorHandler>();
            services.AddTransient <TokenHandler>();
            services.AddTransient <UserInfoHandler>();
            services.AddTransient <IntrospectionHandler>();
            services.AddTransient <RegistrationHandler>();
            var provider        = services.BuildServiceProvider();
            var evtHandlerStore = new EvtHandlerStore(provider);

            evtHandlerStore.Register(typeof(AuthorizationHandler));
            evtHandlerStore.Register(typeof(OpenIdErrorHandler));
            evtHandlerStore.Register(typeof(TokenHandler));
            evtHandlerStore.Register(typeof(UserInfoHandler));
            evtHandlerStore.Register(typeof(IntrospectionHandler));
            evtHandlerStore.Register(typeof(RegistrationHandler));
            if (handlers != null)
            {
                foreach (var handler in handlers)
                {
                    evtHandlerStore.Register(handler);
                }
            }

            services.AddSingleton(typeof(IEvtHandlerStore), evtHandlerStore);
            services.AddTransient <IEventPublisher, FakeBus>();
            return(services);
        }