/// <summary> /// Configure Limitless for startup. /// </summary> private void Configure() { _log.Debug("Configuring Project Limitless..."); _log.Info($"Settings| Default system name set as {_settings.Core.Name}"); _log.Info($"Settings| {_settings.Core.EnabledModules.Length} module(s) will be loaded"); foreach (string moduleName in _settings.Core.EnabledModules) { // Load each module specified in the config. First try to load // the module as DLL, if it can't be found, load it as a // builtin module that is part of this assembly. IModule module = null; try { module = CoreContainer.Instance.ModuleManager.Load(moduleName); } catch (DllNotFoundException ex) { _log.Warning($"Unable to load module '{ex.Message}', attempting to load as builtin module"); // Create a type from the builtin module name var builtinType = Type.GetType(moduleName, true, false); module = CoreContainer.Instance.ModuleManager.LoadBuiltin(moduleName, builtinType); } if (module == null) { _log.Error($"Unable to load module '{moduleName}'"); continue; } _log.Info($"Loaded module '{moduleName}'"); Integrate(moduleName, module); } //TODO: Setup the admin API - move to own module _adminModule = new AdminModule(_log); var routes = _adminModule.GetAPIRoutes(); if (CoreContainer.Instance.RouteManager.AddRoutes(routes)) { _log.Info($"Added {routes.Count} new API routes for module 'AdminModule'"); } else { _log.Warning($"Unable to add all API routes for module 'AdminModule'. Possible duplicate route and method."); } if (_settings.Core.API.Nancy.DashboardEnabled) { _log.Warning($"The Nancy dashboard is enabled at '/{_settings.Core.API.Nancy.DashboardPath}'. It should only be enabled for debugging of the API."); } // When debug output is enabled, print the loaded routes foreach (var route in CoreContainer.Instance.RouteManager.GetRoutes()) { _log.Debug($"Added route '{route.Method.ToString().ToUpper()} {route.Path}'"); } //TODO: Setup the diagnostics CoreContainer.Instance.Settings = _settings; }