예제 #1
0
        private List <PluginWrapper> UpdateSinglePlugin(
            PluginUpdateSettings plugin,
            PluginSourceDownloader pluginSourceDownloader,
            PluginFilter pluginFilter,
            PluginCompiler pluginCompiler,
            PluginLoader pluginLoader
            )
        {
            pluginSourceDownloader.Update(plugin);
            var sourcePluginDirectory   = new DirectoryInfo(Path.Combine(SourcePluginsDirectory, plugin.Name?.Value));
            var compiledPluginDirectory = new DirectoryInfo(Path.Combine(CompiledPluginsDirectory, plugin.Name?.Value));

            if (!pluginFilter.ShouldCompilePlugin(sourcePluginDirectory, compiledPluginDirectory))
            {
                return(null);
            }

            var dependencyTasks  = PluginCopyFiles.CopyDependencies(sourcePluginDirectory, compiledPluginDirectory);
            var settingsTasks    = PluginCopyFiles.CopySettings(sourcePluginDirectory, compiledPluginDirectory);
            var staticFilesTasks = PluginCopyFiles.CopyStaticFiles(sourcePluginDirectory, compiledPluginDirectory);

            Task.WaitAll(dependencyTasks?.ToArray());
            var assembly = pluginCompiler.CompilePlugin(sourcePluginDirectory, compiledPluginDirectory.FullName);

            Task.WaitAll(settingsTasks?.ToArray());
            Task.WaitAll(staticFilesTasks?.ToArray());
            var pluginWrapper = pluginLoader.Load(compiledPluginDirectory, assembly);

            return(pluginWrapper);
        }
예제 #2
0
        public List <Task <List <PluginWrapper> > > UpdateAndLoadAllAsync()
        {
            var tasks = new List <Task <List <PluginWrapper> > >();

            if (!PluginsUpdateSettings.Enable)
            {
                DebugWindow.LogMsg($"Plugin Auto Update is deactivated!");
                return(tasks);
            }

            var pluginCompiler = new PluginCompiler(new DirectoryInfo(RootDirectory));

            foreach (var plugin in PluginsUpdateSettings.Plugins)
            {
                tasks.Add(Task.Run(() => UpdateSinglePlugin(plugin, PluginSourceDownloader, PluginFilter, pluginCompiler, PluginLoader)));
            }
            return(tasks);
        }