Exemple #1
0
        /// <summary>
        /// Start configuration of event store.
        /// </summary>
        /// <param name="cfg"></param>
        /// <returns></returns>
        public static EventStoreConfiguration EventStore(this BaseConfiguration cfg)
        {
            if (cfg.ContainsKey(EventStore_SettingsKey))
            {
                throw new InvalidOperationException("You should not configure EventStore twice.");
            }
            cfg.Set(EventStore_SettingsKey, true);

            return(new EventStoreConfiguration(cfg));
        }
Exemple #2
0
        /// <summary>
        /// Start configuration of messages bus and scan for message handlers in the supplied assemblies.
        /// </summary>
        /// <param name="cfg"></param>
        /// <param name="assemblies"></param>
        /// <param name="messageHandlerConvention"></param>
        /// <returns></returns>
        public static MessageBusConfiguration MessageBus(this BaseConfiguration cfg, IEnumerable <Assembly> assemblies, IMessageHandlerConvention messageHandlerConvention = null)
        {
            if (cfg.ContainsKey(MessageBus_SettingsKey))
            {
                throw new InvalidOperationException("You should not configure MessageBus twice.");
            }
            cfg.Set(MessageBus_SettingsKey, true);

            Condition.Requires(assemblies, "assemblies").IsNotNull();

            // Also scan core message handlers
            assemblies = assemblies.Union(new Assembly[] { Assembly.GetExecutingAssembly() });

            MessageDispatcher dispatcher = MessageBusConfigurationExtensions.GetDispatcher(cfg);

            dispatcher.RegisterMessageHandlers(assemblies, messageHandlerConvention ?? new DefaultMessageHandlerConvention());

            return(new MessageBusConfiguration(cfg));
        }