示例#1
0
        public void Start()
        {
            if (_started)
            {
                return;
            }
            _msn = new Msn(MsnGetters);

            #region First run
            if (Settings.Get <bool>(_names.FirstRun))
            {
                var firstRunModule = new FirstRun(delegate()
                {
                    var module = new OsuPathResolver();
                    if (AddModule(module))
                    {
                        StartModule(module);
                    }
                });
                AddModule(firstRunModule);
                StartModule(firstRunModule);
                if (!firstRunModule.CompletedSuccesfully)
                {
                    Program.SafeQuit();
                }
            }
            MsnGetters.Clear();
            #endregion

            var mapStringFormatter = new MapStringFormatter(new MainMapDataGetter(_mapDataFinders, _mapDataGetters, _mapDataParsers, _mapDataReplacementSetters, _saver, _logger));
            StartModule(mapStringFormatter);

            _logger.Log("Starting...", LogLevel.Advanced);
            _logger.Log(">Main classes...", LogLevel.Advanced);
            _sqliteControler = new SqliteControler(new SqliteConnector());

            _logger.Log(">Modules...", LogLevel.Advanced);
            StartModules();
            _logger.Log(">loaded {0} modules, where {1} are providing settings", LogLevel.Basic, _modules.Count.ToString(), SettingsList.Count.ToString());

            #region plugins
            //TODO: plugin loading
            #endregion plugins

            Settings.Add(_names.FirstRun.Name, false);
            _started = true;
            _logger.Log("Started!", LogLevel.Basic);
        }
示例#2
0
        public void Start()
        {
            if (_started)
            {
                return;
            }
            _msn = new Msn(MsnGetters);

            #region First run

            bool shouldForceFirstRun = false;
            var  lastVersionStr      = Settings.Get <string>(_names.LastRunVersion);
            if (lastVersionStr == _names.LastRunVersion.Default <string>())
            {
                shouldForceFirstRun = true;
            }
            else
            {
                try
                {
                    var lastVersion      = Helpers.Helpers.GetDateFromVersionString(lastVersionStr);
                    var versionToResetOn = Helpers.Helpers.GetDateFromVersionString("v161030.20");
                    shouldForceFirstRun = lastVersion < versionToResetOn;
                }
                catch (Exception e)
                {
                    if (e is FormatException || e is ArgumentNullException)
                    {
                        shouldForceFirstRun = true;
                    }
                    else
                    {
                        throw;
                    }
                }
            }

            if (Settings.Get <bool>(_names.FirstRun) || shouldForceFirstRun)
            {
                var firstRunModule = new FirstRun(delegate()
                {
                    var module = new OsuPathResolver();
                    if (AddModule(module))
                    {
                        StartModule(module);
                    }
                });
                AddModule(firstRunModule);
                StartModule(firstRunModule);
                if (!firstRunModule.CompletedSuccesfully)
                {
                    Program.SafeQuit();
                }
            }
            MsnGetters.Clear();
            #endregion

            var mapStringFormatter = new MapStringFormatter(new MainMapDataGetter(_mapDataFinders, _mapDataGetters, _mapDataParsers, _mapDataReplacementSetters, _saver, _logger, Settings));
            AddModule(mapStringFormatter);

            _logger.Log("Starting...", LogLevel.Advanced);
            _logger.Log(">Main classes...", LogLevel.Advanced);
            _sqliteControler = new SqliteControler(new SqliteConnector());

            _logger.Log(">Modules...", LogLevel.Advanced);
            StartModules();
            _logger.Log(">loaded {0} modules, where {1} are providing settings", LogLevel.Basic, _modules.Count.ToString(), SettingsList.Count.ToString());

            #region plugins
            //TODO: plugin loading
            #endregion plugins

            Settings.Add(_names.FirstRun.Name, false);
            Settings.Add(_names.LastRunVersion.Name, Program.ScVersion);
            _started = true;
            _logger.Log("Started!", LogLevel.Basic);
        }
示例#3
0
        public void Start()
        {
            if (_started)
            {
                return;
            }

            #region First run

            bool shouldForceFirstRun = false;
            var  lastVersionStr      = Settings.Get <string>(_names.LastRunVersion);
            if (lastVersionStr == _names.LastRunVersion.Default <string>())
            {
                shouldForceFirstRun = true;
            }
            else
            {
                try
                {
                    var lastVersion      = Helpers.Helpers.GetDateFromVersionString(lastVersionStr);
                    var versionToResetOn = Helpers.Helpers.GetDateFromVersionString("v180209.13");
                    shouldForceFirstRun = lastVersion < versionToResetOn;
                }
                catch (Exception e)
                {
                    if (e is FormatException || e is ArgumentNullException)
                    {
                        shouldForceFirstRun = true;
                    }
                    else
                    {
                        throw;
                    }
                }
            }

            _logger.Log("Preloading plugins", LogLevel.Advanced);

            var plugins = GetPlugins();


            if (Settings.Get <bool>(_names.FirstRun) || shouldForceFirstRun)
            {
                var firstRunControls = new List <FirstRunUserControl>();

                var firstRunControlProviders =
                    plugins.Where(p => p.GetType().GetInterfaces().Contains(typeof(IFirstRunControlProvider))).ToList();


                foreach (var plugin in firstRunControlProviders)
                {
                    LoadPlugin(plugin);
                    firstRunControls.AddRange(((IFirstRunControlProvider)plugin).GetFirstRunUserControls());
                }
                _logger.Log(">Early loaded {0} plugins for firstRun setup", LogLevel.Advanced, firstRunControlProviders.Count.ToString());

                var firstRunModule = new FirstRun(firstRunControls);

                AddModule(firstRunModule);
                StartModule(firstRunModule);
                if (!firstRunModule.CompletedSuccesfully)
                {
                    Program.SafeQuit();
                }
            }
            MsnGetters.Clear();
            #endregion



            _logger.Log("Starting...", LogLevel.Advanced);
            _logger.Log(">Main classes...", LogLevel.Advanced);
            _sqliteControler = new SqliteControler(new SqliteConnector(_logger));

            _logger.Log(">Modules...", LogLevel.Advanced);
            StartModules();
            _logger.Log(">loaded {0} modules, where {1} are providing settings", LogLevel.Basic, _modules.Count.ToString(), SettingsList.Count.ToString());

            #region plugins
            _logger.Log("Initalizing {0} plugins", LogLevel.Advanced, plugins.Count.ToString());

            _logger.Log("==========", LogLevel.Advanced);

            foreach (var plugin in plugins)
            {
                LoadPlugin(plugin);
            }
            _logger.Log("==========", LogLevel.Advanced);

            ProritizePluginsUsage();
            #endregion plugins

            Settings.Add(_names.FirstRun.Name, false);
            Settings.Add(_names.LastRunVersion.Name, Program.ScVersion);

            var mapStringFormatter = new MapStringFormatter(
                new MainMapDataGetter(_mapDataFinders, _mapDataGetters, _mapDataParsers, _mapDataReplacementSetters, _saver, _logger, Settings),
                _osuEventSources);

            AddModule(mapStringFormatter);
            StartModule(mapStringFormatter);

            _started = true;
            _logger.Log("Started!", LogLevel.Basic);
        }