Ejemplo n.º 1
0
        public static async Task <IServiceProvider> Create()
        {
            var serviceCollection = new ServiceCollection();

            var settingsJson = File.ReadAllText(@"settings.json");
            var settings     = JsonConvert.DeserializeObject <Settings>(settingsJson);

            serviceCollection.AddSingleton <Log4NetLogger>(Log4NetLogger.Create());

            serviceCollection.AddSingleton <Settings>(settings);

            serviceCollection.AddSingleton <VTuberRankingService>();

            serviceCollection.AddSingleton <TwitterService>(new TwitterService(settings.Twitter));

            serviceCollection.AddSingleton <YouTubeBlobService>(new YouTubeBlobService(settings.AzureCloudStorageConnectionString));

            serviceCollection.AddSingleton <VTuberInsightCrawler>();

            serviceCollection.AddSingleton <YouTubeChannelRssCrawler>();

            var youttubeService = await YoutubeServiceCreator.Create(settings.AzureCloudStorageConnectionString);

            serviceCollection.AddSingleton <YouTubeService>(youttubeService);

            return(serviceCollection.BuildServiceProvider());
        }
Ejemplo n.º 2
0
        public List <IFieldDataPlugin> LoadPlugins()
        {
            var pluginBundles = Root
                                .GetFiles("*.plugin");

            var installedPluginFolders = pluginBundles
                                         .Select(InstallPlugin)
                                         .ToList();

            if (!installedPluginFolders.Any())
            {
                throw new ExpectedException($"You need to have at least one local *.plugin file at '{Root.FullName}'");
            }

            var stalePluginFolders = Root
                                     .GetDirectories()
                                     .Where(d => !installedPluginFolders.Contains(d.FullName))
                                     .ToList();

            foreach (var stalePluginFolder in stalePluginFolders)
            {
                Log.Info($"Deleting stale local plugin folder '{stalePluginFolder.FullName}'");
                stalePluginFolder.Delete(true);
            }

            return(new PluginLoader
            {
                Log = Log4NetLogger.Create(Log)
            }
                   .LoadPlugins(installedPluginFolders));
        }
Ejemplo n.º 3
0
        public List <PluginLoader.LoadedPlugin> LoadPlugins()
        {
            RemoveExtractedPluginFolders();

            var pluginFiles = Root
                              .GetFiles("*.plugin")
                              .Select(fi => fi.FullName)
                              .ToList();

            if (!pluginFiles.Any())
            {
                throw new ExpectedException($"You need to have at least one local *.plugin file at '{Root.FullName}'");
            }

            var loadedPlugins = new PluginLoader
            {
                Log     = Log4NetLogger.Create(Log),
                Verbose = Verbose
            }
            .LoadPlugins(pluginFiles);

            var jsonPlugin = loadedPlugins
                             .FirstOrDefault(lp => IsJsonPlugin(lp.Manifest));

            if (jsonPlugin != null)
            {
                var result = AssemblyQualifiedNameParser.Parse(jsonPlugin.Manifest.AssemblyQualifiedTypeName);

                JsonPluginVersion = AquariusServerVersion.Create(result.Version);
                JsonPluginPath    = jsonPlugin.Path;
            }

            return(loadedPlugins);
        }
        public List <PluginLoader.LoadedPlugin> LoadPlugins()
        {
            RemoveExtractedPluginFolders();

            var pluginFiles = Root
                              .GetFiles("*.plugin")
                              .Select(fi => fi.FullName)
                              .ToList();

            if (!pluginFiles.Any())
            {
                throw new ExpectedException($"You need to have at least one local *.plugin file at '{Root.FullName}'");
            }

            return(new PluginLoader
            {
                Log = Log4NetLogger.Create(Log),
                Verbose = Verbose
            }
                   .LoadPlugins(pluginFiles));
        }