static Kernel GetDefaultKernel(CommonConfigData config, KernelLoadDirective loadDirective) { //Find MB 3 server ConnectToServer(config); var repository = new MB3ApiRepository(); var localRepo = GetLocalRepository(); var kernel = new Kernel() { PlaybackControllers = new List <BasePlaybackController>(), //MetadataProviderFactories = MetadataProviderHelper.DefaultProviders(), CommonConfigData = config, //ServiceConfigData = ServiceConfigData.FromFile(ApplicationPaths.ServiceConfigFile), StringData = LocalizedStrings.Instance, ImageResolvers = DefaultImageResolvers(false), MB3ApiRepository = repository, LocalRepo = localRepo, MediaLocationFactory = new MediaLocationFactory(), }; //Kernel.UseNewSQLRepo = config.UseNewSQLRepo; // kernel.StringData.Save(); //save this in case we made mods (no other routine saves this data) if (LoadContext == MBLoadContext.Core) { kernel.PlaybackControllers.Add(new PlaybackController()); } //kernel.EntityResolver = DefaultResolver(kernel.ConfigData); //need a blank root in case plug-ins will add virtual items kernel.RootFolder = new AggregateFolder { Name = "My Media", Id = new Guid("{F6109BAE-CA26-4746-9EBC-1CD233A7B56F}") }; //create our default config panels with localized names kernel.AddConfigPanel(kernel.StringData.GetString("GeneralConfig"), ""); kernel.AddConfigPanel(kernel.StringData.GetString("ViewOptionsConfig"), ""); kernel.AddConfigPanel(kernel.StringData.GetString("ThemesConfig"), ""); //kernel.AddConfigPanel(kernel.StringData.GetString("ParentalControlConfig"), ""); //kick off log clean up task if needed if (config.LastLogCleanup < DateTime.UtcNow.AddDays(-7)) { Async.Queue("Logfile cleanup", () => { Logger.ReportInfo("Running Logfile clean-up..."); var minDateModified = DateTime.UtcNow.AddDays(-(config.LogFileRetentionDays)); foreach (var source in new DirectoryInfo(ApplicationPaths.AppLogPath).GetFileSystemInfos("*.log") .Where(f => f.LastWriteTimeUtc < minDateModified)) { try { source.Delete(); } catch (Exception e) { Logger.ReportException("Error deleting log file {0}", e, source.Name); } } config.LastLogCleanup = DateTime.UtcNow; config.Save(); }); } return(kernel); }