Beispiel #1
0
        private static void AddHandlers(this IServiceCollection services, IEnumerable <Assembly> assembliesToScan)
        {
            assembliesToScan = assembliesToScan as Assembly[] ?? assembliesToScan.ToArray();

            foreach (var type in assembliesToScan.SelectMany(a => a.ExportedTypes))
            {
                if (type.CanBeCastTo(typeof(ISaga)))
                {
                    services.AddScoped(type);
                    SagaConfiguratorCache.Cache(type);
                }
                else if (type.CanBeCastTo(typeof(IConsumer)))
                {
                    services.AddScoped(type);
                    ConsumerConfiguratorCache.Cache(type);
                }
            }
        }
Beispiel #2
0
        public static void LoadFrom(this IReceiveEndpointConfigurator configurator,
                                    IServiceCollection serviceCollection, IServiceProvider services)
        {
            IList <Type> concreteTypes = FindTypes <IConsumer>(serviceCollection, x => !x.HasInterface <ISaga>());

            if (concreteTypes.Count > 0)
            {
                foreach (Type concreteType in concreteTypes)
                {
                    ConsumerConfiguratorCache.Configure(concreteType, configurator, services);
                }
            }

            IList <Type> sagaTypes = FindTypes <ISaga>(serviceCollection, x => true);

            if (sagaTypes.Count > 0)
            {
                foreach (Type sagaType in sagaTypes)
                {
                    SagaConfiguratorCache.Configure(sagaType, configurator, services);
                }
            }
        }