Example #1
0
        public void Run()
        {
            var mediator = new DictionaryServiceFactoryBuilder()
                           .AddRequestHandler(new AppendHelloRequestHandler())
                           .Build()
                           .AsMediator();

            var loginRequest = new LoginRequest("Anna");

            mediator.Send(loginRequest, out string response);

            Console.WriteLine(response);
        }
Example #2
0
        public void Run()
        {
            var mediator = new DictionaryServiceFactoryBuilder()
                           .AddNotificationHandler(new LineRequestHandler())
                           .AddNotificationHandler(new PrintNotificationHandler())
                           .AddNotificationHandler(new LineRequestHandler())

                           .Build()
                           .AsMediator();

            var loginRequest = new LoginRequest("Anna");

            mediator.Publish(loginRequest);
        }
Example #3
0
 public static DictionaryServiceFactoryBuilder AddRequestHandler <TRequest, TResponse>(this DictionaryServiceFactoryBuilder self, IRequestHandler <TRequest, TResponse> handler)
     where TRequest : IRequest <TResponse> =>
 self.AddRequestHandler(typeof(TRequest), handler);
Example #4
0
 public static DictionaryServiceFactoryBuilder AddNotificationHandler <TNotification>(this DictionaryServiceFactoryBuilder self, INotificationHandler <TNotification> handler)
     where TNotification : INotification =>
 self.AddNotificationHandler(typeof(TNotification), handler);