예제 #1
0
        public virtual void Initialize(IChromelyContainer container, IChromelyConfiguration config, IChromelyLogger chromelyLogger)
        {
            EnsureExpectedWorkingDirectory();

            if (config == null)
            {
                var configurator = new ConfigurationHandler();
                config = configurator.Parse <DefaultConfiguration>();
            }

            if (config == null)
            {
                config = new DefaultConfiguration();
            }

            InitConfiguration(config);

            if (chromelyLogger == null)
            {
                chromelyLogger = new SimpleLogger();
            }

            var defaultLogger = new DefaultLogger();

            defaultLogger.Log = chromelyLogger;
            Logger.Instance   = defaultLogger;

            config.Platform = ChromelyRuntime.Platform;

            _container = container;
            if (_container == null)
            {
                _container = new SimpleContainer();
            }

            // Register all primary objects
            _container.RegisterInstance(typeof(IChromelyContainer), typeof(IChromelyContainer).Name, _container);
            _container.RegisterInstance(typeof(IChromelyConfiguration), typeof(IChromelyConfiguration).Name, config);
            _container.RegisterInstance(typeof(IChromelyLogger), typeof(IChromelyLogger).Name, chromelyLogger);
        }
예제 #2
0
        public virtual void Initialize(IChromelyContainer container, IChromelyAppSettings appSettings, IChromelyConfiguration config, IChromelyLogger chromelyLogger)
        {
            EnsureExpectedWorkingDirectory();

            #region Container

            _container = container;
            if (_container == null)
            {
                _container = new SimpleContainer();
            }

            #endregion

            #region Configuration

            if (config == null)
            {
                var configurator = new ConfigurationHandler();
                config = configurator.Parse <DefaultConfiguration>();
            }

            if (config == null)
            {
                config = DefaultConfiguration.CreateForRuntimePlatform();
            }

            InitConfiguration(config);
            config.Platform = ChromelyRuntime.Platform;

            #endregion

            #region Application/User Settings

            if (appSettings == null)
            {
                appSettings = new DefaultAppSettings(config.AppName);
            }

            var currentAppSettings = new CurrentAppSettings();
            currentAppSettings.Properties = appSettings;
            ChromelyAppUser.App           = currentAppSettings;
            ChromelyAppUser.App.Properties.Read(config);

            #endregion

            #region Logger

            if (chromelyLogger == null)
            {
                chromelyLogger = new SimpleLogger();
            }

            var defaultLogger = new DefaultLogger();
            defaultLogger.Log = chromelyLogger;
            Logger.Instance   = defaultLogger;

            #endregion

            // Register all primary objects
            _container.RegisterInstance(typeof(IChromelyContainer), typeof(IChromelyContainer).Name, _container);
            _container.RegisterInstance(typeof(IChromelyAppSettings), typeof(IChromelyAppSettings).Name, appSettings);
            _container.RegisterInstance(typeof(IChromelyConfiguration), typeof(IChromelyConfiguration).Name, config);
            _container.RegisterInstance(typeof(IChromelyLogger), typeof(IChromelyLogger).Name, chromelyLogger);
        }