Example #1
0
        internal void DoStart()
        {
            ConsoleWriteLine();
            ConsoleWriteLine("Starting Repository...");
            ConsoleWriteLine();

            if (_settings.TraceCategories != null)
            {
                LoggingSettings.SnTraceConfigurator.UpdateCategories(_settings.TraceCategories);
            }
            else
            {
                LoggingSettings.SnTraceConfigurator.UpdateStartupCategories();
            }

            InitializeLogger();

            RegisterAppdomainEventHandlers();

            if (_settings.IndexPath != null)
            {
                Providers.Instance.SearchManager.IndexDirectoryPath = _settings.IndexPath;
            }

            LoadAssemblies(_settings.IsWebContext);

            _settings.Services.GetRequiredService <SecurityHandler>().StartSecurity(_settings.IsWebContext, _settings.Services);

            //UNDONE: modernize TemplateManager
            // Set legacy collection from the new services collection and reset the
            // current singleton list to force the system to regenerate it.
            TemplateManager.TemplateReplacerInstances =
                _settings.Services.GetService <IEnumerable <TemplateReplacerBase> >()?.ToArray() ??
                Array.Empty <TemplateReplacerBase>();
            TemplateManager.Clear();

            SnQueryVisitor.VisitorExtensionTypes = new[] { typeof(Sharing.SharingVisitor) };

            // We have to log the access provider here because it cannot be logged
            // during creation as it would lead to a circular reference.
            SnLog.WriteInformation($"AccessProvider created: {AccessProvider.Current?.GetType().FullName}");

            using (new SystemAccount())
                StartManagers();

            if (_settings.TraceCategories != null)
            {
                LoggingSettings.SnTraceConfigurator.UpdateCategories(_settings.TraceCategories);
            }
            else
            {
                LoggingSettings.SnTraceConfigurator.UpdateCategories();
            }

            InitializeOAuthProviders();

            ConsoleWriteLine();
            ConsoleWriteLine("Repository has started.");
            ConsoleWriteLine();

            _startupInfo.Started = DateTime.UtcNow;
        }