コード例 #1
0
        public void Init()
        {
            try
            {
                CoreContainer.SetUp(new WindsorContainer());
                CoreContainer.Container.Register(Component.For <IIranMarketerDatabase>().ImplementedBy <IranMarketerDatabase>());
                CoreContainer.Container.Register(Component.For <ISession>().ImplementedBy <IranMarketerSession>());
                FromAssemblyDescriptor fromAssemblyInDirectoryUserManagement = Classes.FromAssemblyInDirectory(new AssemblyFilter(PathHelper.BinPath(), "*.UserManagement.dll"));
                CoreContainer.Container.Register(fromAssemblyInDirectoryUserManagement.BasedOn(typeof(IService <,>)).WithService.DefaultInterfaces());
                CoreContainer.Container.Register(fromAssemblyInDirectoryUserManagement.BasedOn(typeof(IRepository <,>)).WithService.AllInterfaces());
                CoreContainer.Container.Register(fromAssemblyInDirectoryUserManagement.BasedOn(typeof(BaseMapper <>)).WithServiceBase().WithServiceSelf().LifestyleTransient());

                FromAssemblyDescriptor fromAssemblyInDirectoryApi = Classes.FromAssemblyInDirectory(new AssemblyFilter(PathHelper.BinPath(), "*.API.dll"));
                CoreContainer.Container.Register(fromAssemblyInDirectoryApi.BasedOn(typeof(AbstractProvider <, ,>)).WithService.AllInterfaces().WithServiceBase().WithServiceSelf().LifestyleTransient());


                FromAssemblyDescriptor fromAssemblyInDirectoryApiBasic = Classes.FromAssemblyInDirectory(new AssemblyFilter(PathHelper.BinPath(), "*.API.dll"));
                CoreContainer.Container.Register(fromAssemblyInDirectoryApi.BasedOn(typeof(BaseProvider)).WithService.AllInterfaces().WithServiceBase().WithServiceSelf().LifestyleTransient());

                FromAssemblyDescriptor fromAssemblyInDirectorySetting = Classes.FromAssemblyInDirectory(new AssemblyFilter(PathHelper.BinPath(), "*.Service.dll"));
                CoreContainer.Container.Register(fromAssemblyInDirectorySetting.BasedOn(typeof(BaseSettingService)).WithService.AllInterfaces().WithServiceBase().WithServiceSelf().LifestyleTransient());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
        public void Init(WindsorContainer windsor)
        {
            try
            {
                if (CoreContainer.Initialized)
                {
                    return;
                }
                CoreContainer.SetUp(windsor);
                //SqlRepoSqlServerCastleInstaller.Load( CoreContainer.Container);

                //var connectionProvider = new AppSettingsConnectionProvider();
                //containerBuilder.RegisterInstance(connectionProvider)
                //    .As<IMsSqlConnectionProvider>();
                //CoreContainer.Container.Register(Component.For<ISqlLogger>().ImplementedBy<CustomSqlLogger>());
                CoreContainer.Container.Register(Component.For <ISqlLogWriter>().ImplementedBy <ConsoleSqlLogger>());
                CoreContainer.Container.Register(Component.For <ISqlLogWriter>().ImplementedBy <NoOpSqlLogger>());
                CoreContainer.Container.Register(Component.For <IRepositoryFactory>().ImplementedBy <RepositoryFactory>());
                CoreContainer.Container.Register(Component.For <IStatementFactoryProvider>().ImplementedBy <MsSqlStatementFactoryProvider>());
                CoreContainer.Container.Register(Component.For <IStatementFactory>().ImplementedBy <StatementFactory>());
                CoreContainer.Container.Register(Component.For <IEntityMapper>().ImplementedBy <DapperEntityMapper>());
                CoreContainer.Container.Register(Component.For <IStatementExecutor>().ImplementedBy <DapperStatementExecutor>());
                CoreContainer.Container.Register(Component.For <IWritablePropertyMatcher>().ImplementedBy <WritablePropertyMatcher>());
                CoreContainer.Container.Register(Component.For <IRepositoryFactory>().ImplementedBy <IRepositoryFactory>());

                // CoreContainer.Container.Register(Component.For<ISqlLogger>().ImplementedBy<CustomSqlLogger>());
            }
            catch (Exception ex)
            {
                throw;
            }
        }
コード例 #3
0
        static void Main(string[] args)
        {
            CoreContainer.SetUp(new WindsorContainer());
            //CoreContainer.Container.Register(Component.For<INewRepository>().ImplementedBy<NewRepository>());
            //CoreContainer.Container.Register(Component.For<IWorldRepository>().ImplementedBy<WorldRepository>());
            //CoreContainer.Container.Register(Component.For<ITestSession>().ImplementedBy<TestSession>());
            CoreContainer.Container.Register(Component.For <IMyDatabaseSettings>().ImplementedBy <MyDatabaseSettings>());
            CoreContainer.Container.Register(Component.For <ISession>().ImplementedBy <TestSession>());

            SharedDataTest sharedDataTest = new SharedDataTest();
            var            x = sharedDataTest.GetSectors();
            int            a = 0;
        }
コード例 #4
0
        static void Main(string[] args)
        {
            CoreContainer.SetUp(new WindsorContainer());
            //CoreContainer.Container.Register(Component.For<INewRepository>().ImplementedBy<NewRepository>());
            //CoreContainer.Container.Register(Component.For<IWorldRepository>().ImplementedBy<WorldRepository>());
            //CoreContainer.Container.Register(Component.For<ITestSession>().ImplementedBy<TestSession>());
            CoreContainer.Container.Register(Component.For <IMyDatabaseSettings>().ImplementedBy <MyDatabaseSettings>());
            CoreContainer.Container.Register(Component.For <ISession>().ImplementedBy <TestSession>());



            TestClass2 class2 = new TestClass2();

            //TestClass.Test();
            class2.GetTest();
        }