Beispiel #1
0
        private static void Main()
        {
            ICommand    command    = new CreateUserCommand("*****@*****.**", "hello", "John", "Smith");
            ICommandBus commandBus = new SimpleCommandBus();

            commandBus.RegisterHandler(command, new CreateUserHandler(new InMemoryUsers()));
            commandBus.Handle(command);
        }
 public CqsModule()
 {
     CommandBus      = new SimpleCommandBus();
     QueryBus        = new SimpleQueryBus();
     EventBus        = new SimpleEventBus();
     RequestReplyBus = new SimpleRequestReplyBus();
     _requestMethod  = GetType().GetMethod("ExecuteRequest", BindingFlags.NonPublic | BindingFlags.Instance);
     _commandMethod  = GetType().GetMethod("ExecuteCommand", BindingFlags.NonPublic | BindingFlags.Instance);
     _queryMethod    = GetType().GetMethod("ExecuteQuery", BindingFlags.NonPublic | BindingFlags.Instance);
 }
        public void RealTestForSecurityRule()
        {
            IDependencyContainer container = new LightInjectContainer();

            container.RegisterCommandHandler <TestAuthenticatedCommand, TestAuthenticatedCommandHandler>();
            container.RegisterSecurityRule <TestAuthenticatedCommand, TestSecurityRule <TestAuthenticatedCommand> >();

            var bus = new SimpleCommandBus(container);

            var command = new TestAuthenticatedCommand(new FrameworkClaimsIdentity(Guid.Empty));

            bus.Send(command);
        }
Beispiel #4
0
        private static CqsServer CreateServer()
        {
            var cmdBus = new SimpleCommandBus();
            cmdBus.Register(typeof (Program).Assembly);

            var queryBus = new SimpleQueryBus();
            queryBus.Register(typeof (Program).Assembly);

            var requestReplyBus = new SimpleRequestReplyBus();
            requestReplyBus.Register(typeof (Program).Assembly);

            var eventBus = new SimpleEventBus();
            eventBus.Register(typeof (Program).Assembly);

            var server = new CqsServer(cmdBus, queryBus, eventBus, requestReplyBus);
            server.SerializerFactory = () => new JsonMessageSerializer();
            
            return server;
        }
Beispiel #5
0
        private static CqsHttpListener CreateServer()
        {
            //can be an ioc bus too.
            var commandBus = new SimpleCommandBus();

            commandBus.Register(Assembly.GetExecutingAssembly());

            var queryBus = new SimpleQueryBus();

            queryBus.Register(Assembly.GetExecutingAssembly());

            //takes care of execution
            var processor = new CqsMessageProcessor {
                CommandBus = commandBus, QueryBus = queryBus
            };

            //receive through HTTP
            var server = new CqsHttpListener(processor);

            return(server);
        }
Beispiel #6
0
        public async Task Try_server_and_client_together()
        {
            //can be an ioc bus too.
            var commandBus = new SimpleCommandBus();

            commandBus.Register(Assembly.GetExecutingAssembly());

            //takes care of execution
            var processor = new CqsMessageProcessor {
                CommandBus = commandBus
            };

            //receive through HTTP
            var server = new CqsHttpListener(processor);

            server.Map(typeof(RaiseHands));
            server.Start(new IPEndPoint(IPAddress.Loopback, 0));

            //Our cqs HTTP client.
            var client = new CqsHttpClient("http://localhost:" + server.LocalPort);
            await client.ExecuteAsync(new RaiseHands { Reason = "all YOUR base" });
        }
Beispiel #7
0
        private static CqsServer CreateServer()
        {
            var cmdBus = new SimpleCommandBus();

            cmdBus.Register(typeof(Program).Assembly);

            var queryBus = new SimpleQueryBus();

            queryBus.Register(typeof(Program).Assembly);

            var requestReplyBus = new SimpleRequestReplyBus();

            requestReplyBus.Register(typeof(Program).Assembly);

            var eventBus = new SimpleEventBus();

            eventBus.Register(typeof(Program).Assembly);

            var server = new CqsServer(cmdBus, queryBus, eventBus, requestReplyBus);

            server.SerializerFactory = () => new JsonMessageSerializer();

            return(server);
        }