private static void initializeDependency()
        {
            var container = new CastleWindsorContainer();

            container.RegisterImplementationOf((IContainer)container);
            container.WindsorContainer.AddFacility <EventRegisterFacility>();
            container.WindsorContainer.AddFacility <TypedFactoryFacility>();

            container.Register <IObjectBaseFactory, ObjectBaseFactory>(LifeStyle.Singleton);
            container.AddRegister(x => x.FromType <PresenterRegister>());
            container.AddRegister(x => x.FromType <UIRegister>());
            container.AddRegister(x => x.FromType <CoreRegister>());
            container.AddRegister(x => x.FromType <EngineRegister>());
            container.AddRegister(x => x.FromType <TestRegister>());
            container.AddRegister(x => x.FromType <InfrastructureRegister>());

            container.Register <IDimensionFactory, DimensionFactory>(LifeStyle.Singleton);
            container.Register <IApplicationController, ApplicationController>(LifeStyle.Singleton);
            container.Register <ICompression, SharpLibCompression>();
            container.Register <IEventPublisher, EventPublisher>(LifeStyle.Singleton);
            container.Register <IStringCompression, StringCompression>(LifeStyle.Singleton);
            container.Register <ILogger, OSPLogger>(LifeStyle.Singleton);
            container.RegisterImplementationOf(getCurrentContext());

            container.Register(typeof(IRepository <>), typeof(ImplementationRepository <>));

            IoC.InitializeWith(container);

            var register = new CoreSerializerRegister();

            IoC.Container.AddRegister(x => x.FromInstance(register));
            register.PerformMappingForSerializerIn(IoC.Container);
        }
        private IContainer performInitialization(ApiConfig apiConfig)
        {
            var container = new AutofacContainer();

            container.RegisterImplementationOf((IContainer)container);

            var serializerRegister = new CoreSerializerRegister();

            using (container.OptimizeDependencyResolution())
            {
                container.RegisterImplementationOf(new SynchronizationContext());
                container.AddRegister(x => x.FromType <CoreRegister>());
                container.AddRegister(x => x.FromType <InfrastructureRegister>());
                container.AddRegister(x => x.FromType <InfrastructureImportRegister>());
                container.AddRegister(x => x.FromType <RRegister>());

                registerCoreDependencies(container);

                container.AddRegister(x => x.FromInstance(serializerRegister));
            }

            serializerRegister.PerformMappingForSerializerIn(container);

            initializeConfiguration(container, apiConfig);

            initializeDimensions(container);

            loadPKParameterRepository(container);

            return(container);
        }
        private static void initializeDependency()
        {
//         var container = new AutofacContainer();
//         container.AddActivationHook<EventRegistrationHook>();
            var container = new CastleWindsorContainer();

            container.AddFacility <EventRegisterFacility>();
            container.AddFacility <TypedFactoryFacility>();


            IoC.InitializeWith(container);
            var serializerRegister = new CoreSerializerRegister();

            using (container.OptimizeDependencyResolution())
            {
                container.RegisterImplementationOf((IContainer)container);

                container.Register <IObjectBaseFactory, ObjectBaseFactory>(LifeStyle.Singleton);
                container.AddRegister(x => x.FromType <PresenterRegister>());
                container.AddRegister(x => x.FromType <UIRegister>());
                container.AddRegister(x => x.FromType <CoreRegister>());
                container.AddRegister(x => x.FromType <TestRegister>());
                container.AddRegister(x => x.FromType <InfrastructureRegister>());
                container.AddRegister(x => x.FromType <InfrastructureExportRegister>());
                container.AddRegister(x => x.FromType <InfrastructureSerializationRegister>());
                container.AddRegister(x => x.FromType <InfrastructureImportRegister>());
                container.AddRegister(x => x.FromInstance(serializerRegister));

                container.Register <IDimensionFactory, DimensionFactory>(LifeStyle.Singleton);
                container.Register <IApplicationController, ApplicationController>(LifeStyle.Singleton);
                container.Register <IEventPublisher, EventPublisher>(LifeStyle.Singleton);
                container.RegisterImplementationOf(getCurrentContext());
                container.Register <IHistoryManager, HistoryManager <MyContext> >();
                container.Register <IFullPathDisplayResolver, FullPathDisplayResolver>();
                container.Register <MyContext, MyContext>();
                container.Register <IConfigurableContainerLayoutView, AccordionLayoutView>();


                container.Register <DxContainer, DxContainer>(LifeStyle.Singleton);
//            container.AutofacBuilder.Register(c => c.Resolve<DxContainer>().ApplicationMenu).As<ApplicationMenu>();
//            container.AutofacBuilder.Register(c => c.Resolve<DxContainer>().BarManager).As<BarManager>();
//            container.AutofacBuilder.Register(c => c.Resolve<DxContainer>().PanelControl).As<PanelControl>();
//            container.AutofacBuilder.Register(c => c.Resolve<DxContainer>().RibbonControl).As<RibbonControl>();
//            container.AutofacBuilder.Register(c => c.Resolve<DxContainer>().RibbonBarManager).As<RibbonBarManager>();
//            container.AutofacBuilder.Register(c => c.Resolve<DxContainer>().UserLookAndFeel).As<UserLookAndFeel>();
//            container.AutofacBuilder.Register(c => c.Resolve<DxContainer>().XtraTabbedMdiManager).As<XtraTabbedMdiManager>();

                container.Register <RegionsContainer, RegionsContainer>(LifeStyle.Singleton);
//            container.AutofacBuilder.Register(c => c.Resolve<RegionsContainer>().Journal).Keyed<IRegion>(RegionNames.Journal.Name);
//            container.AutofacBuilder.Register(c => c.Resolve<RegionsContainer>().Comparison).Keyed<IRegion>(RegionNames.Comparison.Name);
//            container.AutofacBuilder.Register(c => c.Resolve<RegionsContainer>().Explorer).Keyed<IRegion>(RegionNames.Explorer.Name);
            }


            serializerRegister.PerformMappingForSerializerIn(IoC.Container);
        }
        public void PerformMappingForSerializerIn(IContainer container)
        {
            var coreSerializerRepository = container.Resolve <IOSPSuiteXmlSerializerRepository>();

            coreSerializerRepository.AddPresentationSerializers();
            _register.PerformMappingForSerializerIn(container);

            var mobiSerializerRepository = container.Resolve <IMoBiXmlSerializerRepository>();

            mobiSerializerRepository.PerformMapping();
        }
        public override void RegisterInContainer(IContainer container)
        {
            container.AddScanner(scan =>
            {
                scan.AssemblyContainingType <InfrastructureRegister>();

                //ORM Repository should be registered as singleton
                scan.ExcludeNamespaceContainingType <SpeciesRepository>();

                //this type will be registered using another convention
                scan.ExcludeNamespaceContainingType <IObjectConverter>();             //Converter
                scan.ExcludeNamespaceContainingType <IReportBuilder>();               //report builder
                scan.ExcludeNamespaceContainingType <SimulationReporter>();           //tex reporter
                scan.ExcludeNamespaceContainingType <IndividualTeXBuilder>();         //tex builder
                scan.ExcludeNamespaceContainingType <PKSimXmlSerializerRepository>(); //Serializer

                scan.ExcludeType <CommandMetaDataRepository>();
                scan.ExcludeType <DefaultIndividualRetriever>();
                scan.ExcludeType <SessionManager>();
                scan.ExcludeType <TemplateDatabase>();
                scan.ExcludeType <ProteinExpressionDatabase>();
                scan.ExcludeType <ProteinExpressionQueries>();
                scan.ExcludeType <ModelDatabase>();
                scan.ExcludeType <VersionChecker>();
                scan.ExcludeType <Workspace>();

                //already registered
                scan.ExcludeType <PKSimXmlSerializerRepository>();
                scan.ExcludeType <PKSimConfiguration>();
                scan.ExcludeType <SerializationContext>();

                scan.WithConvention <PKSimRegistrationConvention>();
            });

            container.AddScanner(scan =>
            {
                scan.AssemblyContainingType <InfrastructureRegister>();
                scan.IncludeNamespaceContainingType <SpeciesRepository>(); //Repository

                scan.IncludeType <CommandMetaDataRepository>();
                scan.IncludeType <DefaultIndividualRetriever>();
                scan.IncludeType <SessionManager>();
                scan.IncludeType <TemplateDatabase>();
                scan.IncludeType <ProteinExpressionDatabase>();
                scan.IncludeType <ProteinExpressionQueries>();
                scan.IncludeType <ModelDatabase>();

                scan.IncludeType <VersionChecker>();

                scan.RegisterAs(LifeStyle.Singleton);
                scan.WithConvention <OSPSuiteRegistrationConvention>();
            });

            container.Register <IWorkspace, Workspace>(LifeStyle.Singleton);

            registerConverters(container);

            registerReportBuilders(container);

            registerTexReporters(container);

            container.Register <ICompression, SharpLibCompression>();
            container.Register <IStringCompression, StringCompression>();
            container.Register <IProjectRetriever, PKSimProjectRetriever>();
            container.Register <IObservedDataConfiguration, ImportObservedDataTask>();
            container.Register <IFlatContainerIdToContainerMapperSpecification, FlatContainerIdToFormulationMapper>();
            container.Register <IFileLocker, FileLocker>(LifeStyle.Singleton);

            registerORMDependencies();

            var xmlRegister = new CoreSerializerRegister();

            container.AddRegister(x => x.FromInstance(xmlRegister));
            var sbsuiteSerializerRepository = container.Resolve <IOSPSuiteXmlSerializerRepository>();

            sbsuiteSerializerRepository.AddPresentationSerializers();
            xmlRegister.PerformMappingForSerializerIn(container);

            container.AddRegister(x => x.FromType <ReportingRegister>());
            container.AddRegister(x => x.FromType <OSPSuite.TeXReporting.ReportingRegister>());
            container.AddRegister(x => x.FromType <OSPSuite.Infrastructure.InfrastructureRegister>());

            //register factory also as IObjectBaseFactoryIBuildTrackerFactory
            var factory = container.Resolve <IPKSimObjectBaseFactory>() as IObjectBaseFactory;

            container.RegisterImplementationOf(factory);

            var configuration  = container.Resolve <IPKSimConfiguration>();
            var versionChecker = container.Resolve <IVersionChecker>();

            versionChecker.VersionFileUrl = CoreConstants.VERSION_FILE_URL;
            versionChecker.CurrentVersion = configuration.Version;
            versionChecker.ProductName    = CoreConstants.PRODUCT_NAME;
        }
        public override void GlobalContext()
        {
            if (IoC.Container != null)
            {
                return;
            }

            base.GlobalContext();
            var container = new CastleWindsorContainer();

            IoC.InitializeWith(container);
            IoC.RegisterImplementationOf(IoC.Container);

            container.WindsorContainer.AddFacility <TypedFactoryFacility>();
            container.Register <IObjectBaseFactory, ObjectBaseFactory>(LifeStyle.Singleton);
            container.Register <IDimensionFactory, DimensionFactoryForIntegrationTests>(LifeStyle.Singleton);
            container.Register <IGroupRepository, GroupRepositoryForSpecs>(LifeStyle.Singleton);
            container.Register <IDisplayNameProvider, DisplayNameProvider>();
            container.Register <SimulationHelperForSpecs, SimulationHelperForSpecs>();
            container.Register <ModelHelperForSpecs, ModelHelperForSpecs>();
            container.Register <ConcentrationBaseModelHelperForSpecs, ConcentrationBaseModelHelperForSpecs>();
            container.Register <IReactionDimensionRetriever, ReactionDimensionRetrieverForSpecs>(LifeStyle.Singleton);
            container.Register(typeof(IRepository <>), typeof(ImplementationRepository <>));
            container.RegisterImplementationOf(A.Fake <IStartOptions>());

            var stringCompression = A.Fake <IStringCompression>();

            A.CallTo(() => stringCompression.Compress(A <string> ._)).ReturnsLazily(x => x.GetArgument <string>(0));
            A.CallTo(() => stringCompression.Decompress(A <string> ._)).ReturnsLazily(x => x.GetArgument <string>(0));
            container.RegisterImplementationOf(stringCompression);

            container.RegisterImplementationOf(A.Fake <IObjectTypeResolver>());
            container.RegisterImplementationOf(A.Fake <IDisplayUnitRetriever>());
            container.RegisterImplementationOf(A.Fake <IDataRepositoryTask>());
            container.RegisterImplementationOf(A.Fake <IOSPSuiteExecutionContext>());
            container.RegisterImplementationOf(A.Fake <IProjectRetriever>());
            container.RegisterImplementationOf(A.Fake <IApplicationDiscriminator>());
            container.RegisterImplementationOf(A.Fake <IRelatedItemDescriptionCreator>());
            container.RegisterImplementationOf(A.Fake <IJournalDiagramManagerFactory>());
            container.RegisterImplementationOf(A.Fake <ICoreUserSettings>());
            container.RegisterImplementationOf(A.Fake <ICoreSimulationFactory>());

            var applicationConfiguration = A.Fake <IApplicationConfiguration>();

            A.CallTo(() => applicationConfiguration.Product).Returns(Origins.Other);
            container.RegisterImplementationOf(applicationConfiguration);

            initGroupRepository();

            var progressMananager = A.Fake <IProgressManager>();

            A.CallTo(() => progressMananager.Create()).Returns(A.Fake <IProgressUpdater>());
            container.RegisterImplementationOf(progressMananager);

            using (container.OptimizeDependencyResolution())
            {
                container.AddRegister(x => x.FromType <CoreRegister>());
                container.AddRegister(x => x.FromType <InfrastructureRegister>());
                var register = new CoreSerializerRegister();
                container.AddRegister(x => x.FromInstance(register));
                register.PerformMappingForSerializerIn(container);
            }

            initializeDimensions();

            Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory;
        }
        public override void GlobalContext()
        {
            if (IoC.Container != null)
            {
                return;
            }

            base.GlobalContext();
            var container = new CastleWindsorContainer();

            IoC.InitializeWith(container);
            IoC.RegisterImplementationOf(IoC.Container);

            container.WindsorContainer.AddFacility <TypedFactoryFacility>();
            container.Register <IObjectBaseFactory, ObjectBaseFactory>(LifeStyle.Singleton);
            container.Register <IDimensionFactory, DimensionFactoryForIntegrationTests>(LifeStyle.Singleton);
            container.Register <IGroupRepository, GroupRepositoryForSpecs>(LifeStyle.Singleton);
            container.Register <IDataRepositoryTask, DataRepositoryTask>();
            container.Register <IImporter, Importer>();
            container.Register <IDataSourceFileParser, DataSourceFileParser>();
            container.Register <ICsvDataSourceFile, CsvDataSourceFile>();
            container.Register <IImportLogger, ImportLogger>();
            container.Register <IExcelDataSourceFile, ExcelDataSourceFile>();
            container.Register <IDataSetToDataRepositoryMapper, DataSetToDataRepositoryMapper>();
            container.Register <IDataFormat, MixColumnsDataFormat>();

            container.Register <SimulationHelperForSpecs, SimulationHelperForSpecs>();
            container.Register <ModelHelperForSpecs, ModelHelperForSpecs>();
            container.Register <IDisplayNameProvider, DisplayNameProvider>();
            container.Register <ConcentrationBaseModelHelperForSpecs, ConcentrationBaseModelHelperForSpecs>();
            container.Register <IReactionDimensionRetriever, ReactionDimensionRetrieverForSpecs>(LifeStyle.Singleton);
            container.RegisterImplementationOf(A.Fake <IStartOptions>());

            container.RegisterImplementationOf(A.Fake <IApplicationController>());
            container.RegisterImplementationOf(A.Fake <IObjectTypeResolver>());
            container.RegisterImplementationOf(A.Fake <IDisplayUnitRetriever>());
            container.RegisterImplementationOf(A.Fake <IOSPSuiteExecutionContext>());
            container.RegisterImplementationOf(A.Fake <IProjectRetriever>());
            container.RegisterImplementationOf(A.Fake <IApplicationDiscriminator>());
            container.RegisterImplementationOf(A.Fake <IRelatedItemDescriptionCreator>());
            container.RegisterImplementationOf(A.Fake <IJournalDiagramManagerFactory>());
            container.RegisterImplementationOf(A.Fake <ICoreUserSettings>());
            container.RegisterImplementationOf(A.Fake <ICoreSimulationFactory>());

            var applicationConfiguration = A.Fake <IApplicationConfiguration>();

            A.CallTo(() => applicationConfiguration.Product).Returns(Origins.Other);
            container.RegisterImplementationOf(applicationConfiguration);

            initGroupRepository();

            var progressManager = A.Fake <IProgressManager>();

            A.CallTo(() => progressManager.Create()).Returns(A.Fake <IProgressUpdater>());
            container.RegisterImplementationOf(progressManager);

            var csvSeparatorSelector = A.Fake <ICsvSeparatorSelector>();

            A.CallTo(() => csvSeparatorSelector.GetCsvSeparator(A <string> .Ignored)).Returns(';');
            container.RegisterImplementationOf(csvSeparatorSelector);


            using (container.OptimizeDependencyResolution())
            {
                container.AddRegister(x => x.FromType <CoreRegister>());
                container.AddRegister(x => x.FromType <InfrastructureRegister>());
                var register = new CoreSerializerRegister();
                container.AddRegister(x => x.FromInstance(register));
                register.PerformMappingForSerializerIn(container);
            }


            initializeDimensions();
            initPKParameters();

            Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory;
        }