コード例 #1
0
        public void ActiveRecordUnitOfWorkFacilityWillRegisterIRepositoryAndUnitOfWorkFactory()
        {
            RhinoContainer container = new RhinoContainer(@"Binsor\UnitOfWorkFacilities.boo");

            Assert.IsTrue(container.Kernel.HasComponent(typeof(IRepository <>)));
            Assert.IsTrue(container.Kernel.HasComponent(typeof(IUnitOfWorkFactory)));
        }
コード例 #2
0
 public void CanGetInterfaceByPredicate()
 {
     RhinoContainer container = new RhinoContainer(@"Binsor\UsingAllTypes.boo");
     IHandler handler = container.Kernel.GetHandler("foo54");
     Assert.IsNotNull(handler);
     Assert.AreEqual(typeof(IFoo54), handler.ComponentModel.Service);
     Assert.AreEqual(typeof(Fubar54), handler.ComponentModel.Implementation);
 }
コード例 #3
0
 public void CanGetAllTypesByPredicate()
 {
     RhinoContainer container = new RhinoContainer(@"Binsor\UsingAllTypes.boo");
     IHandler handler = container.Kernel.GetHandler("nh.repos");
     Assert.IsNotNull(handler);
     Assert.AreEqual(typeof(IRepository<>), handler.ComponentModel.Service.GetGenericTypeDefinition());
     Assert.AreEqual(typeof(NHRepository<>), handler.ComponentModel.Implementation);
 }
コード例 #4
0
 public void CanCreateActiveRecordUnitOfWorkFacility()
 {
     RhinoContainer container = new RhinoContainer(@"Binsor\UnitOfWorkFacilities.boo");
     IFacility[] facilities = container.Kernel.GetFacilities();
     ActiveRecordUnitOfWorkFacility activeRecordUnitOfWorkFactory = (ActiveRecordUnitOfWorkFacility)facilities[0];
     Assert.AreEqual(System.Reflection.Assembly.Load("Rhino.Commons.Binsor"),
         activeRecordUnitOfWorkFactory.Assemblies[0]);
 }
コード例 #5
0
        public void ContainerUsesXmlConfigurationIfNotBooExtension()
        {
            RhinoContainer container = new RhinoContainer(@"Binsor\Windsor.xml");

            ISender sender = container.Resolve <ISender>();

            Assert.IsNotNull(sender);
        }
コード例 #6
0
        public void CanGetInterfaceByPredicate()
        {
            RhinoContainer container = new RhinoContainer(@"Binsor\UsingAllTypes.boo");
            IHandler       handler   = container.Kernel.GetHandler("foo54");

            Assert.IsNotNull(handler);
            Assert.AreEqual(typeof(IFoo54), handler.ComponentModel.Service);
            Assert.AreEqual(typeof(Fubar54), handler.ComponentModel.Implementation);
        }
コード例 #7
0
        public void CanGetAllTypesByPredicate()
        {
            RhinoContainer container = new RhinoContainer(@"Binsor\UsingAllTypes.boo");
            IHandler       handler   = container.Kernel.GetHandler("nh.repos");

            Assert.IsNotNull(handler);
            Assert.AreEqual(typeof(IRepository <>), handler.ComponentModel.Service.GetGenericTypeDefinition());
            Assert.AreEqual(typeof(NHRepository <>), handler.ComponentModel.Implementation);
        }
コード例 #8
0
        public void CanCreateActiveRecordUnitOfWorkFacility()
        {
            RhinoContainer container = new RhinoContainer(@"Binsor\UnitOfWorkFacilities.boo");

            IFacility[] facilities = container.Kernel.GetFacilities();
            ActiveRecordUnitOfWorkFacility activeRecordUnitOfWorkFactory = (ActiveRecordUnitOfWorkFacility)facilities[0];

            Assert.AreEqual(System.Reflection.Assembly.Load("Rhino.Commons.Binsor"),
                            activeRecordUnitOfWorkFactory.Assemblies[0]);
        }
 public void CanExtendComponentsRegisteredInFacilities()
 {
     using (IWindsorContainer container = new RhinoContainer())
     {
         string path = Path.GetFullPath(@"Binsor\PreRegistrationWithExtensions.boo");
         BooReader.Read(container, path);
         ShippingCalculator calculator = container.Resolve <ShippingCalculator>();
         Assert.AreEqual(120m, calculator.ShippingCost);
     }
 }
        public void CanExtendComponentsRegisteredInFacilities()
        {
            using (IWindsorContainer container = new RhinoContainer())
            {
                string path = Path.GetFullPath(@"Binsor\PreRegistrationWithExtensions.boo");
                BooReader.Read(container, path);
                ShippingCalculator calculator = container.Resolve<ShippingCalculator>();
                Assert.AreEqual(120m, calculator.ShippingCost);

            }
        }
コード例 #11
0
        public void CanUseEnvironmentInfoPassedInToContainer()
        {
            Assert.IsFalse(_container.Kernel.HasComponent("foo_bar"));

            string         path      = Path.GetFullPath(@"Binsor\Windsor2.boo");
            RhinoContainer container = new RhinoContainer(path, new TestEnvironmentInfo("Binsor2"));
            Fubar          fubar     = container.Resolve <Fubar>("foo_bar");

            Assert.IsNotNull(fubar);
            Assert.AreEqual("Binsor2", fubar.Foo);
        }
        public void CanExtendComponentsRegisteredInCode()
        {
            using (IWindsorContainer container = new RhinoContainer())
            {
                container.Register(Component.For <GstCalculator>()
                                   .Named("gstcalculator")
                                   .DependsOn(Property.ForKey("GstRate").Eq(15m)));

                IWindsorInstaller installer = BinsorScript.Inline(new StringBuilder().AppendLine("extend \"gstcalculator\":")
                                                                  .AppendLine("	GstRate = decimal(50)").ToString());
                installer.Install(container, null);
                GstCalculator calculator = container.Resolve <GstCalculator>();
                Assert.AreEqual(50m, calculator.GstRate);
            }
        }
        public void CanExtendComponentsRegisteredInCode()
        {
            using (IWindsorContainer container = new RhinoContainer())
            {
                container.Register(Component.For<GstCalculator>()
                    .Named("gstcalculator")
                    .DependsOn(Property.ForKey("GstRate").Eq(15m)));

                IWindsorInstaller installer = BinsorScript.Inline(new StringBuilder().AppendLine("extend \"gstcalculator\":")
                                        .AppendLine("	GstRate = decimal(50)").ToString());
                installer.Install(container, null);
                GstCalculator calculator = container.Resolve<GstCalculator>();
                Assert.AreEqual(50m, calculator.GstRate);
            }
        }
コード例 #14
0
ファイル: Program.cs プロジェクト: JackWangCUMT/rhino-tools
 static void Main(string[] args)
 {
     try
     {
         RhinoContainer container = new RhinoContainer("Windsor.boo");
         IoC.Initialize(container);
         ContainerSelector containerSelector = IoC.Resolve<ContainerSelector>();
         containerSelector.PrintChildContainers();
         using(UnitOfWork.Start())
         {
             Console.WriteLine(
                 NHibernateUnitOfWorkFactory.CurrentNHibernateSession
                     .Connection.ConnectionString
                 );
         }
         using(containerSelector.Enter("Northwind"))
         {
             using (UnitOfWork.Start())
             {
                 Console.WriteLine(
                     NHibernateUnitOfWorkFactory.CurrentNHibernateSession
                         .Connection.ConnectionString
                     );
             }
         }
         using (containerSelector.Enter("Southsand"))
         {
             using (UnitOfWork.Start())
             {
                 Console.WriteLine(
                     NHibernateUnitOfWorkFactory.CurrentNHibernateSession
                         .Connection.ConnectionString
                     );
             }
         }
     }
     catch (Exception e)
     {
         System.Console.WriteLine(e);
     }
 }
コード例 #15
0
 static void Main(string[] args)
 {
     try
     {
         RhinoContainer container = new RhinoContainer("Windsor.boo");
         IoC.Initialize(container);
         ContainerSelector containerSelector = IoC.Resolve <ContainerSelector>();
         containerSelector.PrintChildContainers();
         using (UnitOfWork.Start())
         {
             Console.WriteLine(
                 NHibernateUnitOfWorkFactory.CurrentNHibernateSession
                 .Connection.ConnectionString
                 );
         }
         using (containerSelector.Enter("Northwind"))
         {
             using (UnitOfWork.Start())
             {
                 Console.WriteLine(
                     NHibernateUnitOfWorkFactory.CurrentNHibernateSession
                     .Connection.ConnectionString
                     );
             }
         }
         using (containerSelector.Enter("Southsand"))
         {
             using (UnitOfWork.Start())
             {
                 Console.WriteLine(
                     NHibernateUnitOfWorkFactory.CurrentNHibernateSession
                     .Connection.ConnectionString
                     );
             }
         }
     }
     catch (Exception e)
     {
         System.Console.WriteLine(e);
     }
 }
コード例 #16
0
ファイル: Program.cs プロジェクト: MichalGrzegorzak/Ylvis
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            RhinoContainer container = new RhinoContainer(".\\config\\Windsor.config");
            IoC.Initialize(container);
            container.Kernel.AddFacility("nh", new NHibernateUnitOfWorkFacility());

            EnableNhibernateLogging();
            CreateDB(container);
            FirstUseOfRepository();

            //_ieForm = new IeTestingForm(); 
            
            ////if no password & login then show config form
            //MbankSettings settings = Properties.Settings.Default.MyMbankSettings;
            //if (settings == null)
            //{
            //    _ieForm.Visible = false;
            //    Form configForm = new ConfigureMbank();
            //    configForm.Closed += new EventHandler(f_Closing);
            //    configForm.Show();
            //}
            //else
            //{
            //    _ieForm.Go(Properties.Settings.Default.MyMbankSettings);
            //}

            //form = new GroupsForm();
            //form.Show();

            CreditFormMVP form = new CreditFormMVP();
            CreditPresenter creditPresenter = new CreditPresenter(new Credit(), form);
            //form.Show();

            //Application.Run(_ieForm);
            Application.Run(form);
        }
コード例 #17
0
ファイル: Program.cs プロジェクト: MichalGrzegorzak/Ylvis
        private static void PrepareDatabase(bool createDB)
        {
            try
            {
                Configuration cfg = new Configuration().Configure(@"hibernate.cfg.xml"); //must be in root dir
                ISessionFactory factory = cfg.BuildSessionFactory();

                if (createDB)
                {
                    new SchemaExport(cfg).Create(true, true); // creates structure at database 
                }
                RhinoContainer container = new RhinoContainer(".\\config\\Windsor.config");
                IoC.Initialize(container);

                IoC.Container.Kernel.AddComponentInstance("nhibernate_cfg", cfg);
                IoC.Resolve<IUnitOfWorkFactory>().Init();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw e;
            }
        }
コード例 #18
0
        public void ContainerUsesXmlConfigurationIfNotBooExtension()
        {
            RhinoContainer container = new RhinoContainer(@"Binsor\Windsor.xml");

            ISender sender = container.Resolve<ISender>();
            Assert.IsNotNull(sender);
        }
コード例 #19
0
        public void CanGetAllTypesByNamespace()
        {
            RhinoContainer container = new RhinoContainer(@"Binsor\UsingAllTypes.boo");

            Assert.IsNotNull(container[typeof(UsingAllTypesFixture)]);
        }
コード例 #20
0
        public void ActiveRecordUnitOfWorkFacilityWillRegisterIRepositoryWithRepositoryKey()
        {
            RhinoContainer container = new RhinoContainer(@"Binsor\UnitOfWorkFacilities2.boo");

            Assert.IsTrue(container.Kernel.HasComponent("default_repository"));
        }
コード例 #21
0
        public void CanUseEnvironmentInfoPassedInToContainer()
        {
            Assert.IsFalse(_container.Kernel.HasComponent("foo_bar"));

            string path = Path.GetFullPath(@"Binsor\Windsor2.boo");
            RhinoContainer container = new RhinoContainer(path, new TestEnvironmentInfo("Binsor2"));
            Fubar fubar = container.Resolve<Fubar>("foo_bar");
            Assert.IsNotNull(fubar);
            Assert.AreEqual("Binsor2", fubar.Foo);
        }
コード例 #22
0
 public void CanGetAllTypesByBaseType()
 {
     RhinoContainer container = new RhinoContainer(@"Binsor\UsingAllTypes.boo");
     Assert.IsNotNull(container[typeof(MyView)]);
 }
コード例 #23
0
 public void CanGetAllTypesByAttribute()
 {
     RhinoContainer container = new RhinoContainer(@"Binsor\UsingAllTypes.boo");
     Assert.IsNotNull(container[typeof(Controller)]);
 }
コード例 #24
0
 public void ActiveRecordUnitOfWorkFacilityWillRegisterIRepositoryWithRepositoryKey()
 {
     RhinoContainer container = new RhinoContainer(@"Binsor\UnitOfWorkFacilities2.boo");
     Assert.IsTrue(container.Kernel.HasComponent("default_repository"));
 }
コード例 #25
0
 public void ActiveRecordUnitOfWorkFacilityWillRegisterIRepositoryAndUnitOfWorkFactory()
 {
     RhinoContainer container = new RhinoContainer(@"Binsor\UnitOfWorkFacilities.boo");
     Assert.IsTrue(container.Kernel.HasComponent(typeof (IRepository<>)));
     Assert.IsTrue(container.Kernel.HasComponent(typeof(IUnitOfWorkFactory)));
 }
コード例 #26
0
 public void CanGetAllTypesByNamespace()
 {
     RhinoContainer container = new RhinoContainer(@"Binsor\UsingAllTypes.boo");
     Assert.IsNotNull(container[typeof(UsingAllTypesFixture)]);
 }
コード例 #27
0
        public void CanGetAllTypesByBaseType()
        {
            RhinoContainer container = new RhinoContainer(@"Binsor\UsingAllTypes.boo");

            Assert.IsNotNull(container[typeof(MyView)]);
        }
コード例 #28
0
        public void CanGetAllTypesByAttribute()
        {
            RhinoContainer container = new RhinoContainer(@"Binsor\UsingAllTypes.boo");

            Assert.IsNotNull(container[typeof(Controller)]);
        }