public void IntsToEntities()
        {
            WindsorRegistrar.RegisterSingleton(typeof(IRepo <>), typeof(Repo <>));
            WindsorRegistrar.RegisterSingleton(typeof(IDbContextFactory), typeof(DbContextFactory));
            using (var scope = new TransactionScope())
            {
                var repo     = new Repo <cm.Product>(new DbContextFactory());
                var product1 = new cm.Product {
                    Name = "a"
                };
                var product2 = new cm.Product {
                    Name = "b"
                };

                product1 = repo.Insert(product1);
                product2 = repo.Insert(product2);
                repo.Save();

                var promotionInput = new PromotionInput {
                    Products = new List <int> {
                        product1.Id, product2.Id
                    }
                };
                var promotion = new cm.Promotion();

                promotion.InjectFrom <IntsToEntities>(promotionInput);

                Assert.IsNotNull(promotion.Products);
                Assert.AreEqual(2, promotion.Products.Count);
                Assert.AreEqual(product1.Id, promotion.Products.First().Id);
            }
        }
Example #2
0
        public void IntsToEntities()
        {
            WindsorRegistrar.RegisterSingleton(typeof(IRepo <>), typeof(Repo <>));
            WindsorRegistrar.RegisterSingleton(typeof(IDbContextFactory), typeof(DbContextFactory));
            using (var scope = new TransactionScope())
            {
                var repo  = new Repo <Meal>(new DbContextFactory());
                var meal1 = new Meal {
                    Name = "a"
                };
                var meal2 = new Meal {
                    Name = "b"
                };

                meal1 = repo.Insert(meal1);
                meal2 = repo.Insert(meal2);
                repo.Save();

                var dinnerInput = new DinnerInput {
                    Meals = new int[] { meal1.Id, meal2.Id }
                };
                var dinner = new Dinner();

                dinner.InjectFrom <IntsToEntities>(dinnerInput);

                Assert.IsNotNull(dinner.Meals);
                Assert.AreEqual(2, dinner.Meals.Count);
                Assert.AreEqual(meal1.Id, dinner.Meals.First().Id);
            }
        }
 public override void Configure()
 {
     try
     {
         base.Configure();
         var swcType  = typeof(HandlerWindsorConfigurator);
         var assembly = swcType.Assembly;
         var alltypes = assembly.GetTypes();
         WindsorRegistrar.Register(typeof(BusinessHandlerFactory), typeof(BusinessHandlerFactory));
         var iService     = typeof(IService <>);
         var serviceTypes = alltypes
                            .Where(t => t.IsClass && t.GetInterface(iService.FullName) != null && !t.IsAbstract)
                            .ToList();
         foreach (var type in serviceTypes)
         {
             WindsorRegistrar.Register(type, type);
         }
         WindsorRegistrar.RegisterAllFromAssemblies(assembly.FullName);
     }
     catch (Exception ex)
     {
         ex = new BusinessException("注入服务对象失败!", ex);
         LoggerHelper.Instance.Error(ex);
         throw ex;
     }
 }
        public void IntsToEntities()
        {
            WindsorRegistrar.RegisterSingleton(typeof(IReadRepo <>), typeof(ReadRepo <>));
            WindsorRegistrar.RegisterSingleton(typeof(IDbContextFactory), typeof(DbContextFactory));
            using (var scope = new TransactionScope())
            {
                var repo = new Repo <Meal>(new DbContextFactory());
                var m1   = new Meal {
                    Name = "a"
                };
                var m2 = new Meal {
                    Name = "b"
                };

                repo.Insert(m1);
                repo.Insert(m2);
                repo.Save();

                var s = new DinnerInput {
                    Meals = new List <int> {
                        m1.Id, m2.Id
                    }
                };
                var t = new Dinner();

                t.InjectFrom <IntsToEntities>(s);

                Assert.IsNotNull(t.Meals);
                Assert.AreEqual(2, t.Meals.Count);
                Assert.AreEqual(m1.Id, t.Meals.First().Id);
            }
        }
 public static void Configure()
 {
     WindsorRegistrar.Register(typeof(IFormsAuthentication), typeof(FormAuthService));
     WindsorRegistrar.Register(typeof(IHasher), typeof(Hasher));
     WindsorRegistrar.RegisterAllFromAssemblies("Data");
     WindsorRegistrar.RegisterAllFromAssemblies("Service");
     WindsorRegistrar.RegisterAllFromAssemblies("Infra");
 }
Example #6
0
        public static void Configure()
        {
            WindsorRegistrar.Register <IUserService, UserService>();
            WindsorRegistrar.Register <IFormsAuthentication, FormAuthService>();
            WindsorRegistrar.Register <ICrudService <Video>, VideoService>();
            WindsorRegistrar.Register <IMapper <Video, YoukuVideoInput>, VideoMapper>();

            WindsorRegistrar.registerAllFromAssemblies("Reach");
        }
Example #7
0
 public static void Configure()
 {
     WindsorRegistrar.Register(typeof(IFormsAuthentication), typeof(FormAuthService));
     WindsorRegistrar.Register(typeof(IHasher), typeof(Hasher));
     WindsorRegistrar.Register(typeof(IMapper <Dinner, DinnerInput>), typeof(DinnerMapper));
     WindsorRegistrar.RegisterAllFromAssemblies("Omu.ProDinner.Data");
     WindsorRegistrar.RegisterAllFromAssemblies("Omu.ProDinner.Service");
     WindsorRegistrar.RegisterAllFromAssemblies("Omu.ProDinner.WebUI");
 }
Example #8
0
        public static void Configure()
        {
            WindsorRegistrar.Register(typeof(IHasher), typeof(Hasher));
            WindsorRegistrar.Register(typeof(IUserService), typeof(UserService));
            WindsorRegistrar.Register(typeof(IMealService), typeof(MealService));

            WindsorRegistrar.RegisterAllFromAssemblies("Omu.ProDinner.Data");
            WindsorRegistrar.RegisterAllFromAssemblies("Omu.ProDinner.Service");
            WindsorRegistrar.RegisterAllFromAssemblies("Omu.ProDinner.WebUI");
        }
Example #9
0
        public static void Configure()
        {
            WindsorRegistrar.Register(typeof(IFormsAuthentication), typeof(FormAuthService));
            WindsorRegistrar.Register(typeof(IBuilder <Address, AddressInput>), typeof(AddressBuilder));
            WindsorRegistrar.Register(typeof(IBuilder <User, UserCreateInput>), typeof(UserBuilder <UserCreateInput>));
            WindsorRegistrar.Register(typeof(IBuilder <User, UserEditInput>), typeof(UserBuilder <UserEditInput>));
            WindsorRegistrar.Register(typeof(IBuilder <Dossier, DossierCreateInput>), typeof(DossierBuilder));

            WindsorRegistrar.RegisterAllFromAssemblies("MRGSP.ASMS.Data");
            WindsorRegistrar.RegisterAllFromAssemblies("MRGSP.ASMS.Service");
            WindsorRegistrar.RegisterAllFromAssemblies("MRGSP.ASMS.Infra");
        }
        public static void Configure()
        {
            WindsorRegistrar.Register(typeof(IDbContextFactory), typeof(DbContextFactory));     //数据上下文
            WindsorRegistrar.Register(typeof(IFormsAuthentication), typeof(FormAuthService));   //身份
            WindsorRegistrar.Register(typeof(IHasher), typeof(Hasher));                         //加密
            WindsorRegistrar.Register(typeof(IPlayNumTypeService), typeof(PlayNumTypeService)); //加密


            WindsorRegistrar.RegisterAllFromAssemblies("Ytg.Core");
            WindsorRegistrar.RegisterAllFromAssemblies("Ytg.Data");
            WindsorRegistrar.RegisterAllFromAssemblies("Ytg.Service");
        }
Example #11
0
        public static void Configure()
        {
            WindsorRegistrar.Register(typeof(IFormsAuthentication), typeof(FormAuthService));
            WindsorRegistrar.Register(typeof(IHasher), typeof(Hasher));
            WindsorRegistrar.Register(typeof(IMapper <Promotion, PromotionInput>), typeof(PromotionMapper));
            WindsorRegistrar.Register(typeof(IUserService), typeof(UserService));
            WindsorRegistrar.Register(typeof(IProductService), typeof(ProductService));
            WindsorRegistrar.Register(typeof(IUserBillingInformationService), typeof(UserBillingInformationService));
            WindsorRegistrar.Register(typeof(IApplicationService), typeof(ApplicationService));
            WindsorRegistrar.Register(typeof(IConsumerBillingInformationService), typeof(ConsumerBillingInformationService));


            WindsorRegistrar.RegisterAllFromAssemblies("dFrontierAppWizard.Data");
            WindsorRegistrar.RegisterAllFromAssemblies("dFrontierAppWizard.Service");
            WindsorRegistrar.RegisterAllFromAssemblies("dFrontierAppWizard.WebUI");
        }
Example #12
0
 public override void Configure()
 {
     try
     {
         try
         {
             //注入IService IQueryableUnitOfWork
             WindsorRegistrar.Register(typeof(Db), typeof(Db));
             base.Configure();
             //var swcType = typeof(RepositoryWindsorConfigurator);
             //var assembly = swcType.Assembly;
             //var alltypes = assembly.GetTypes();
             //var repositoryTypes = alltypes
             //    .Where(t => t.IsInterface)
             //    .ToList();
             //foreach (var repositoryType in repositoryTypes)
             //{
             //    var implementationType =
             //        alltypes.FirstOrDefault(t => t.GetInterface(repositoryType.Name) != null);
             //    WindsorRegistrar.Register(repositoryType, implementationType);
             //}
             WindsorRegistrar.Register(typeof(RepositoryProvider), typeof(RepositoryProvider));
             //WindsorRegistrar.RegisterAllFromAssemblies(assembly.FullName);
         }
         catch (Exception ex)
         {
             ex = new BusinessException("注入仓储对象失败!", ex);
             LoggerHelper.Instance.Error(ex);
             throw ex;
         }
     }
     catch (Exception ex)
     {
         throw new AppException("注入配置失败!", ex);
     }
 }