コード例 #1
0
        public static IEventBusBuilder InitEventBus(this IEventBusBuilder builder, Action <IEventBus> configureEventBus)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (configureEventBus != null)
            {
                builder.Configure <EventBusFactoryOptions>(options => options.EventBusInitActions.Add(configureEventBus));
            }

            return(builder);
        }
コード例 #2
0
        /// <summary>
        /// 使用内存事件总线
        /// </summary>
        /// <param name="builder"></param>
        /// <returns></returns>
        public static IEventBusBuilder UseMemory(this IEventBusBuilder builder)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            builder.Services.TryAddTransient <MemoryEventBus>();

            return(builder.Configure <EventBusFactoryOptions>(options =>
            {
                options.EventBusProvider = new MemoryEventBusProvider();
            }));
        }