Exemplo n.º 1
0
        /// <summary>
        /// Registration of CqrsVibe query handlers
        /// </summary>
        /// <param name="services">Service collection</param>
        /// <param name="lifetime">Lifetime</param>
        /// <param name="fromAssemblies">Assemblies containing handlers</param>
        /// <param name="warmUpHandlerInvokersCache">Warm up invokers cache of found handlers</param>
        public static IServiceCollection AddCqrsVibeQueryHandlers(
            this IServiceCollection services,
            ServiceLifetime lifetime,
            IEnumerable <Assembly> fromAssemblies,
            bool warmUpHandlerInvokersCache = true)
        {
            foreach (var handlerTypeDescriptor in AssemblyScanner.FindQueryHandlersFrom(
                         fromAssemblies,
                         warmUpHandlerInvokersCache))
            {
                services.Add(new ServiceDescriptor(
                                 handlerTypeDescriptor.HandlerType,
                                 handlerTypeDescriptor.ImplementationType,
                                 lifetime));
            }

            return(services);
        }