示例#1
0
        public static void Register(Container container)
        {
            container.RegisterPerWebRequest <IOrdersManagement, OrdersManagement>();
            container.RegisterPerWebRequest <IShippingQuery, ShippingQuery>();

            var domainHandler      = Lifestyle.Singleton.CreateRegistration <DomainNotificationHandler>(container);
            var orderPlacedHandler = Lifestyle.Singleton.CreateRegistration <OrderPlacedHandler>(container);

            container.RegisterSingleton <ShippingContext>();
            container.RegisterSingleton <OrderContext>();
            container.RegisterSingleton <IShippingRepository, ShippingRepository>();
            container.RegisterSingleton <IShippingADORepository, ShippingADORepository>();
            container.RegisterSingleton <IOrderRepository, OrderRepository>();



            container.AddRegistration(typeof(INotifiable <DomainNotification>), domainHandler);
            container.AddRegistration(typeof(IMessageHandler <DomainNotification>), domainHandler);
            container.RegisterCollection <IMessageHandler <OrderPlaced> >(new[] { typeof(OrderPlacedHandler).Assembly, typeof(NewOrderForShippingCommandHandler).Assembly });
            container.RegisterCollection <IUnitOfWork>(new[] { typeof(ShippingUnitOfWork).Assembly, typeof(OrderUnitOfWork).Assembly });
        }
示例#2
0
        public static void Initialize(Container container)
        {
            container.RegisterPerWebRequest <UserRegistrationContext>();
            container.RegisterPerWebRequest <IUserRepository, UserRepository>();
            container.RegisterPerWebRequest <IUnitOfWork, UserRegistrationUnitOfWork>();

            container.Register <IEncryptionService, EncryptionService>();

            container.Register <IUserAuthentication, UserAuthentication>();
            container.Register <IUserRegistration, UserRegistration>();


            var domainHandler            = Lifestyle.Singleton.CreateRegistration <DomainNotificationHandler>(container);
            var userRegisteredHadler     = Lifestyle.Singleton.CreateRegistration <UserRegisteredHandler>(container);
            var userAuthenticatedHandler = Lifestyle.Singleton.CreateRegistration <UserAuthenticatedHandler>(container);

            container.AddRegistration(typeof(IHandler <DomainNotification>), domainHandler);
            container.AddRegistration(typeof(INotifiable <DomainNotification>), domainHandler);
            container.AddRegistration(typeof(IHandler <UserRegistered>), userRegisteredHadler);
            container.AddRegistration(typeof(INotifiable <UserRegistered>), userRegisteredHadler);
            container.AddRegistration(typeof(IHandler <UserAuthenticated>), userAuthenticatedHandler);
            container.AddRegistration(typeof(INotifiable <UserAuthenticated>), userAuthenticatedHandler);
        }