Exemple #1
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterRoutes(RouteTable.Routes);

            Runtime = new SimpleCqrsRuntime<UnityServiceLocator>();

            Configure.WithWeb()
                .DefaultBuilder()
                .BinarySerializer()     // Must use binary serializer for types that are not known to NServiceBus (domain events, command bus)
                .SimpleCqrs(Runtime)
                    .UseNsbCommandBus() // Tells SimpleCqrs to create a NsbCommandBus instance, which sends commands over NServiceBus
                .MsmqTransport()
                .UnicastBus()
                    .CreateBus()
                    .Start();

            // The command bus is created for you. (Its an instance of NsbCommandBus)
            // The CommandBusConfig in the Web.config tells the NsbCommandBus where to send the commands,
            // the Commands element is a type name or an assembly name and the Endpoint element specifies where to send the type or types in the assembly
            // you can get it out of the service locator using the line below
            // I use MvcTurbine for website, so I would register the command bus in the MvcTurbine's
            // service locator

            // var commandBus = Runtime.ServiceLocator.Resolve<ICommandBus>();

            // TODO : Go to CustomerController next
        }
Exemple #2
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterRoutes(RouteTable.Routes);

            Runtime = new SimpleCqrsRuntime <UnityServiceLocator>();

            Configure.WithWeb()
            .DefaultBuilder()
            .BinarySerializer()         // Must use binary serializer for types that are not known to NServiceBus (domain events, command bus)
            .SimpleCqrs(Runtime)
            .UseNsbCommandBus()         // Tells SimpleCqrs to create a NsbCommandBus instance, which sends commands over NServiceBus
            .MsmqTransport()
            .UnicastBus()
            .CreateBus()
            .Start();

            // The command bus is created for you. (Its an instance of NsbCommandBus)
            // The CommandBusConfig in the Web.config tells the NsbCommandBus where to send the commands,
            // the Commands element is a type name or an assembly name and the Endpoint element specifies where to send the type or types in the assembly
            // you can get it out of the service locator using the line below
            // I use MvcTurbine for website, so I would register the command bus in the MvcTurbine's
            // service locator

            // var commandBus = Runtime.ServiceLocator.Resolve<ICommandBus>();

            // TODO : Go to CustomerController next
        }
        static MvcApplication()
        {
            DatabaseFactory.SetConnectionName("Mongo");

            var container = new UnityContainer();
            ServiceLocatorManager.SetLocatorProvider(() => new UnityServiceLocator(container));

            var simpleCqrsRuntime = new SimpleCqrsRuntime(container);
            simpleCqrsRuntime.Start();

            simpleCqrsRuntime.ServiceLocator.Register<IEventStore>(
                new SqlServerEventStore(
                    new SqlServerConfiguration(ConfigurationManager.ConnectionStrings["Bennington.ContentTree.Domain.ConnectionString"].ToString()),
                    new JsonDomainEventSerializer()));

            container.RegisterInstance(simpleCqrsRuntime.ServiceLocator.Resolve<ICommandBus>());
            container.RegisterInstance<SimpleCqrs.IServiceLocator>(simpleCqrsRuntime.ServiceLocator);

            Configurer.Configure
            .Content()
                .UseSql("Bennington.ContentTree.Domain.ConnectionString")
                .Run();
        }
Exemple #4
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            //routes.MapRoute(
            //    "Companies", // Route name
            //    "{category}/{page}", // URL with parameters
            //    new { controller = "Companies", action = "List", category = UrlParameter.Optional, page = UrlParameter.Optional } // Parameter defaults
            //    );

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Companies", action = "List", id = UrlParameter.Optional } // Parameter defaults
            );

              //  Configuration.Configure();
            Runtime = new SimpleCqrsRuntime<WindsorServiceLocator>();
            Runtime.Start();

            DependencyResolver.SetResolver(Runtime.ServiceLocator);

            var container = new WindsorContainer();

            container.Register(Component.For<IUserRepository>().ImplementedBy<UserRepository>());
            container.Register(Component.For<IAuthProvider>().ImplementedBy<FormAuthProvider>());

            ControllerBuilder.Current.SetControllerFactory(new CastleControllerFactory(container));

            ReCreateReadModels();
        }