Beispiel #1
0
        public static void Start()
        {
            UI.BootStrapping.ApplicationStartup.Initialize(LogLevel.Debug, registrationAction);

            var container = IoC.Container;

            using (container.OptimizeDependencyResolution())
            {
                container.AddRegister(x => x.FromType <CoreRegister>());
                container.AddRegister(x => x.FromType <PresenterRegister>());
                container.AddRegister(x => x.FromType <InfrastructureRegister>());
                container.AddRegister(x => x.FromType <BatchRegister>());
                container.AddRegister(x => x.FromType <CLIRegister>());

                InfrastructureRegister.RegisterSerializationDependencies();
                InfrastructureRegister.RegisterWorkspace();
                UI.BootStrapping.ApplicationStartup.RegisterCommands(container);
                container.RegisterImplementationOf(new DefaultLookAndFeel().LookAndFeel);
            }

            var skinManager  = container.Resolve <ISkinManager>();
            var userSettings = container.Resolve <IPresentationUserSettings>();

            skinManager.ActivateSkin(userSettings, Constants.DEFAULT_SKIN);
        }
Beispiel #2
0
        public override void GlobalContext()
        {
            if (IoC.Container != null)
            {
                return;
            }

            InfrastructureRegister.Initialize();

            //use only in tests
            var container = IoC.Container;

            using (container.OptimizeDependencyResolution())
            {
                var configuration = container.Resolve <IPKSimConfiguration>();
//            configuration.PKSimDb = DomainHelperForSpecs.DbFilePath;
//            configuration.DimensionFilePath = DomainHelperForSpecs.DimensionFilePath;
//            configuration.PKParametersFilePath = DomainHelperForSpecs.PKParametersFilePath;

                //need to register these serives for which the default implementation is in the UI
                container.RegisterImplementationOf(new SynchronizationContext());
                container.Register <IApplicationController, ApplicationController>(LifeStyle.Singleton);
                container.Register <IExceptionManager, ExceptionManagerForSpecs>(LifeStyle.Singleton);
                container.Register <IDisplayUnitRetriever, MatlabDisplayUnitRetriever>();
                container.Register <IOntogenyFactorsRetriever, OntogenyFactorsRetriever>();

                container.RegisterImplementationOf(A.Fake <IProgressUpdater>());
                container.RegisterImplementationOf(A.Fake <IDialogCreator>());
                container.RegisterImplementationOf(A.Fake <IHistoryManager>());
                container.RegisterImplementationOf(A.Fake <IWorkspace>());
                container.RegisterImplementationOf(A.Fake <OSPSuite.Core.IWorkspace>());
                container.RegisterImplementationOf(A.Fake <IHeavyWorkManager>());
                container.RegisterImplementationOf(A.Fake <IChartTemplatingTask>());
                container.RegisterImplementationOf(A.Fake <IPresentationSettingsTask>());
                container.RegisterImplementationOf(A.Fake <IJournalDiagramManagerFactory>());

                container.AddRegister(x =>
                {
                    x.FromInstance(new CoreRegister());
                    x.FromType <InfrastructureRegister>();
                    x.FromType <PresenterRegister>();
                    x.FromType <OSPSuite.Presentation.PresenterRegister>();
                    x.FromType <BatchRegister>();
                });

                var userSettings = container.Resolve <IUserSettings>();
                userSettings.AbsTol = 1e-10;
                userSettings.RelTol = 1e-5;
                //this is use to create reports
                userSettings.NumberOfBins = CoreConstants.DEFAULT_NUMBER_OF_BINS;


                InfrastructureRegister.RegisterSerializationDependencies();
            }
            //Required for usage with nunit 3
            Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory;
        }
Beispiel #3
0
        public static void Start()
        {
            ApplicationStartup.Initialize();
            var container = IoC.Container;

            using (container.OptimizeDependencyResolution())
            {
                container.AddRegister(x => x.FromType <CoreRegister>());
                container.AddRegister(x => x.FromType <PresenterRegister>());
                container.AddRegister(x => x.FromType <InfrastructureRegister>());
                container.AddRegister(x => x.FromType <BatchRegister>());

                InfrastructureRegister.RegisterSerializationDependencies();
                ApplicationStartup.RegisterCommands(container);

                var workspace = container.Resolve <IWorkspace>();
                container.RegisterImplementationOf((IWithWorkspaceLayout)workspace);
            }
        }
Beispiel #4
0
        private void initializeForMatlab(string dimensionFilePath, string databaseFilePath, string pkParameterFilePath)
        {
            if (IoC.Container != null)
            {
                return;
            }

            InfrastructureRegister.Initialize();
            var container          = IoC.Container;
            var pksimConfiguration = container.Resolve <IPKSimConfiguration>();

            //path was specified, update the default path
            if (!string.IsNullOrEmpty(dimensionFilePath))
            {
                pksimConfiguration.DimensionFilePath = dimensionFilePath;
            }

            //path was specified, update the default path
            if (!string.IsNullOrEmpty(databaseFilePath))
            {
                pksimConfiguration.PKSimDb = databaseFilePath;
            }

            //path was specified, update the default path
            if (!string.IsNullOrEmpty(pkParameterFilePath))
            {
                pksimConfiguration.PKParametersFilePath = pkParameterFilePath;
            }

            using (container.OptimizeDependencyResolution())
            {
                container.RegisterImplementationOf(new SynchronizationContext());
                container.AddRegister(x => x.FromType <MatlabRegister>());
                container.AddRegister(x => x.FromType <PresenterRegister>());
                container.AddRegister(x => x.FromType <CoreRegister>());
                container.AddRegister(x => x.FromType <InfrastructureRegister>());
                container.AddRegister(x => x.FromType <OSPSuite.Presentation.PresenterRegister>());

                //no computation required in matlab interface
                InfrastructureRegister.RegisterSerializationDependencies(registerSimModelSchema: false);
            }
        }
Beispiel #5
0
        public static void Start()
        {
            var container = IoC.Container;

            using (container.OptimizeDependencyResolution())
            {
                container.RegisterImplementationOf(NumericFormatterOptions.Instance);
                container.Register <IApplicationController, ApplicationController>();

                registerCLITypes(container);

                container.AddRegister(x => x.FromType <PresenterRegister>());
                container.AddRegister(x => x.FromType <CoreRegister>());
                container.AddRegister(x => x.FromType <OSPSuite.Presentation.PresenterRegister>());
                container.AddRegister(x => x.FromType <InfrastructureRegister>());
                container.AddRegister(x => x.FromType <CLIRegister>());

                InfrastructureRegister.RegisterSerializationDependencies();
            }
        }
        private IContainer performInitialization()
        {
            // We do not want to register the IoC container to avoid static pollution that may collide with OSPSuite-R
            var container = InfrastructureRegister.Initialize(registerContainerAsStatic: false);

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

            var configuration = container.Resolve <IPKSimConfiguration>();
            var currentPath   = new FileInfo(Assembly.GetAssembly(GetType()).Location).DirectoryName;

            if (!File.Exists(configuration.PKSimDbPath))
            {
                configuration.PKSimDbPath = Path.Combine(currentPath, CoreConstants.PK_SIM_DB_FILE);
            }

            if (!File.Exists(configuration.PKParametersFilePath))
            {
                configuration.PKParametersFilePath = Path.Combine(currentPath, Constants.Files.PK_PARAMETERS_FILE_NAME);
            }

            if (!File.Exists(configuration.DimensionFilePath))
            {
                configuration.DimensionFilePath = Path.Combine(currentPath, Constants.Files.DIMENSIONS_FILE_NAME);
            }

            // This will log the version of PKSIm used to R
            Console.WriteLine(PKSimConstants.Information.InitializingPKSim(CoreConstants.PRODUCT_NAME, configuration.FullVersion));

            // Serialization mapping will require access to PKSim DB and as such, it needs to be performed after the DB was set.
            InfrastructureRegister.LoadDefaultEntities(container);
            return(container);
        }
        private void initializeForMatlab()
        {
            if (IoC.Container != null)
            {
                return;
            }

            var container = InfrastructureRegister.Initialize();

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

                //no computation required in matlab interface
                InfrastructureRegister.RegisterSerializationDependencies();
                container.Register <ICoreWorkspace, OSPSuite.Core.IWorkspace, CLIWorkspace>(LifeStyle.Singleton);
            }
        }
Beispiel #8
0
        private void initializeForMatlab()
        {
            if (IoC.Container != null)
            {
                return;
            }

            InfrastructureRegister.Initialize();
            var container = IoC.Container;

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

                //no computation required in matlab interface
                InfrastructureRegister.RegisterSerializationDependencies(registerSimModelSchema: false);
                InfrastructureRegister.RegisterWorkspace <CLIWorkspace>();
            }
        }
Beispiel #9
0
        public static void Start()
        {
            var container = IoC.Container;

            using (container.OptimizeDependencyResolution())
            {
                container.RegisterImplementationOf(NumericFormatterOptions.Instance);
                container.Register <IApplicationController, ApplicationController>();

                registerCLITypes(container);

                container.AddRegister(x => x.FromType <PresenterRegister>());
                container.AddRegister(x => x.FromType <CoreRegister>());
                container.AddRegister(x => x.FromType <EngineRegister>());
                container.AddRegister(x => x.FromType <OSPSuite.Presentation.PresenterRegister>());
                container.AddRegister(x => x.FromType <InfrastructureRegister>());
                container.AddRegister(x => x.FromType <CLIRegister>());

                InfrastructureRegister.RegisterSerializationDependencies();
                var pkSimConfiguration = container.Resolve <IPKSimConfiguration>();
                XMLSchemaCache.InitializeFromFile(pkSimConfiguration.SimModelSchemaFilePath);
            }
        }
Beispiel #10
0
        public void Start()
        {
            var progressManager = IoC.Resolve <IProgressManager>();
            var container       = IoC.Container;

            using (var progress = progressManager.Create())
            {
                progress.Initialize(8);

                using (container.OptimizeDependencyResolution())
                {
                    showStatusMessage(progress, PKSimConstants.UI.RegisterAssembly(PKSimConstants.UI.Core));
                    container.AddRegister(x => x.FromType <CoreRegister>());

                    showStatusMessage(progress, PKSimConstants.UI.RegisterAssembly(PKSimConstants.UI.Infrastructure));
                    container.AddRegister(x => x.FromType <InfrastructureRegister>());

                    showStatusMessage(progress, message: PKSimConstants.UI.RegisterAssembly(PKSimConstants.UI.Presentation));
                    container.AddRegister(x => x.FromType <Presentation.PresenterRegister>());

                    showStatusMessage(progress, PKSimConstants.UI.RegisterAssembly(PKSimConstants.UI.UserInterface));
                    container.AddRegister(x => x.FromType <UserInterfaceRegister>());

                    showStatusMessage(progress, PKSimConstants.UI.RegisterAssembly(PKSimConstants.UI.Commands));
                    RegisterCommands(container);

                    showStatusMessage(progress, PKSimConstants.UI.RegisterSerializationDependencies);
                    InfrastructureRegister.RegisterSerializationDependencies();

                    finalizeRegistration(container);
                }

                showStatusMessage(progress, PKSimConstants.UI.StartingUserInterface);
                startStartableObject(container);
            }
        }