/// <summary>
        /// Starts the application.  That method should be one of the first being called when the program starts. The method
        /// accepts an existing configuration object.  See <see cref="StartApplication()"/> for default configuration.
        /// </summary>
        /// <param name="config">Loaded application object.</param>
        public void StartApplication(ApplicationConfiguration config)
        {
            _config = config;

            if (ServiceProvider == null) ServiceProvider = new ServiceProvider();
            if (PresentationController == null) PresentationController = new PresentationController();
            if (ObjectContainer == null) ObjectContainer = new ObjectContainer();
            if (ExtensionPortManager == null) ExtensionPortManager = new ExtensionPortManager(ObjectContainer);

            if (_config != null)
            {
                ConfigManager.ConfigureContainer(ObjectContainer, _config);
                ConfigManager.ConfigureServices(ServiceProvider, _config);
                ConfigManager.ConfigureModules(ObjectContainer, _config);
            }

            //start services
            foreach (IService service in ServiceProvider.AllServices)
            {
                IStartable startable;
                startable = service as IStartable;
                if (startable != null) startable.Start();
            }

            //Display the Shell
            if (Shell != null)
            {
                foreach (IViewController ctrl in Shell.CreateViewControllers())
                {
                    PresentationController.ViewControllers.Add(ctrl);
                }
                foreach (IPresenter presenter in Shell.CreatePresenters())
                {
                    PresentationController.RegisterPresenter(presenter);
                }
                Shell.Show();
            }

            //Start modules
            foreach (object obj in ObjectContainer.AllObjects)
            {
                IModule module = obj as IModule;
                if (module != null)
                {
                    module.PresentationController = PresentationController;
                    IStartable start;
                    start = module as IStartable;
                    if (start != null) start.Start();
                }
            }

            _started = true;
        }
Example #2
0
        /// <summary>
        /// Starts the application.  That method should be one of the first being called when the program starts. The method
        /// accepts an existing configuration object.  See <see cref="StartApplication()"/> for default configuration.
        /// </summary>
        /// <param name="config">Loaded application object.</param>
        public void StartApplication(ApplicationConfiguration config)
        {
            _config = config;

            if (ServiceProvider == null)
            {
                ServiceProvider = new ServiceProvider();
            }
            if (PresentationController == null)
            {
                PresentationController = new PresentationController();
            }
            if (ObjectContainer == null)
            {
                ObjectContainer = new ObjectContainer();
            }
            if (ExtensionPortManager == null)
            {
                ExtensionPortManager = new ExtensionPortManager(ObjectContainer);
            }

            if (_config != null)
            {
                ConfigManager.ConfigureContainer(ObjectContainer, _config);
                ConfigManager.ConfigureServices(ServiceProvider, _config);
                ConfigManager.ConfigureModules(ObjectContainer, _config);
            }

            //start services
            foreach (IService service in ServiceProvider.AllServices)
            {
                IStartable startable;
                startable = service as IStartable;
                if (startable != null)
                {
                    startable.Start();
                }
            }

            //Display the Shell
            if (Shell != null)
            {
                foreach (IViewController ctrl in Shell.CreateViewControllers())
                {
                    PresentationController.ViewControllers.Add(ctrl);
                }
                foreach (IPresenter presenter in Shell.CreatePresenters())
                {
                    PresentationController.RegisterPresenter(presenter);
                }
                Shell.Show();
            }

            //Start modules
            foreach (object obj in ObjectContainer.AllObjects)
            {
                IModule module = obj as IModule;
                if (module != null)
                {
                    module.PresentationController = PresentationController;
                    IStartable start;
                    start = module as IStartable;
                    if (start != null)
                    {
                        start.Start();
                    }
                }
            }

            _started = true;
        }