Beispiel #1
0
        static void Main(string[] args)
        {
            var sendEmailHandler   = new UserAddedEventHandlerSendEmail();
            var sendMessageHandler = new UserAddedEventHandlerSendMessage();
            var sendRedbagsHandler = new UserAddedEventHandlerSendRedbags();

            Weiz.EventBus.Core.EventBus.Instance.Subscribe(sendEmailHandler);
            Weiz.EventBus.Core.EventBus.Instance.Subscribe(sendMessageHandler);
            //Weiz.EventBus.Core.EventBus.Instance.Subscribe<UserGeneratorEvent>(sendRedbagsHandler);
            Weiz.EventBus.Core.EventBus.Instance.Subscribe <OrderGeneratorEvent>(sendRedbagsHandler);

            var userGeneratorEvent = new UserGeneratorEvent {
                UserId = Guid.NewGuid()
            };

            System.Console.WriteLine("{0}注册成功", userGeneratorEvent.UserId);

            Weiz.EventBus.Core.EventBus.Instance.Publish(userGeneratorEvent, CallBack);

            var orderGeneratorEvent = new OrderGeneratorEvent {
                OrderId = Guid.NewGuid()
            };

            System.Console.WriteLine("{0}下单成功", orderGeneratorEvent.OrderId);

            Weiz.EventBus.Core.EventBus.Instance.Publish(orderGeneratorEvent, CallBack);

            System.Console.ReadKey();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            var sendEmailHandler   = new UserAddedEventHandlerSendEmail();//实例事件处理对象
            var sendMessageHandler = new UserAddedEventHandlerSendMessage();
            var sendRedbagsHandler = new UserAddedEventHandlerSendRedbags();

            Weiz.EventBus.Core.EventBus.Instance.Subscribe <UserGeneratorEvent>(sendEmailHandler);//注册事件
            Weiz.EventBus.Core.EventBus.Instance.Subscribe <UserGeneratorEvent>(sendMessageHandler);
            Weiz.EventBus.Core.EventBus.Instance.Subscribe <OrderGeneratorEvent>(sendRedbagsHandler);

            Core.EventBus.Instance.Publish(new Events.UserGeneratorEvent {
                UserId = Guid.NewGuid()
            }, CallBack);
            Core.EventBus.Instance.Publish(new Events.OrderGeneratorEvent {
                OrderId = Guid.NewGuid()
            }, CallBack);

            System.Console.ReadKey();
        }