Пример #1
0
        /// <summary>
        /// Registration of CqrsVibe command 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 AddCqrsVibeCommandHandlers(
            this IServiceCollection services,
            ServiceLifetime lifetime,
            IEnumerable <Assembly> fromAssemblies,
            bool warmUpHandlerInvokersCache = true)
        {
            foreach (var handlerTypeDescriptor in AssemblyScanner.FindCommandHandlersFrom(
                         fromAssemblies,
                         warmUpHandlerInvokersCache))
            {
                services.Add(new ServiceDescriptor(
                                 handlerTypeDescriptor.HandlerType,
                                 handlerTypeDescriptor.ImplementationType,
                                 lifetime));
            }

            return(services);
        }