Beispiel #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);
        }
Beispiel #2
0
        private List <PluginWrapper> UpdateSinglePlugin(
            SinglePluginUpdateSettings plugin,
            PluginSourceDownloader pluginSourceDownloader,
            PluginFilter pluginFilter,
            IPluginCompiler pluginCompiler,
            string rootDirectory,
            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);

            /*var txtJsonFilesTask = PluginCopyFiles.CopyTxtAndJsonFromRoot(sourcePluginDirectory, compiledPluginDirectory);*/

            if (dependencyTasks != null)
            {
                Task.WaitAll(dependencyTasks.ToArray());
            }

            var csProjFiles = sourcePluginDirectory
                              .GetFiles("*.csproj", SearchOption.AllDirectories)
                              .Where(f => f.Extension == ".csproj");

            foreach (var csProjFile in csProjFiles)
            {
                pluginCompiler.CompilePlugin(
                    csProjFile,
                    compiledPluginDirectory.FullName,
                    new DirectoryInfo(rootDirectory)
                    );
            }


            if (settingsTasks != null)
            {
                Task.WaitAll(settingsTasks.ToArray());
            }
            if (staticFilesTasks != null)
            {
                Task.WaitAll(staticFilesTasks.ToArray());
            }
            /*txtJsonFilesTask.Wait();*/
            var pluginWrapper = pluginLoader.Load(compiledPluginDirectory);

            return(pluginWrapper);
        }
Beispiel #3
0
        public bool ShouldCompilePlugin(DirectoryInfo SourceDirectory, DirectoryInfo CompiledDirectory)
        {
            if (!SourceDirectory.Exists)
            {
                return(false);
            }
            if (!CompiledDirectory.Exists)
            {
                return(true);
            }

            var compileSettingsDirectory = PluginCopyFiles.GetDirectoryByNamesCompiled(CompiledDirectory, PluginCopyFiles.SettingsDirectoryNames);
            var latestCompileChange      = LatestChangeInDirectory(CompiledDirectory, compileSettingsDirectory);
            var latestSourceChange       = LatestChangeInDirectory(SourceDirectory);

            if (latestSourceChange > latestCompileChange)
            {
                return(true);
            }
            return(false);
        }
Beispiel #4
0
        private List <PluginWrapper> UpdateSinglePlugin(
            SinglePluginUpdateSettings plugin,
            PluginSourceDownloader pluginSourceDownloader,
            PluginFilter pluginFilter,
            IPluginCompiler pluginCompiler,
            string rootDirectory,
            PluginLoader pluginLoader
            )
        {
            var sourcePluginDirectory   = new DirectoryInfo(Path.Combine(SourcePluginsDirectory, plugin.Name?.Value));
            var compiledPluginDirectory = new DirectoryInfo(Path.Combine(CompiledPluginsDirectory, plugin.Name?.Value));

            try
            {
                pluginSourceDownloader.Update(plugin);

                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);
                var txtJsonFilesTask        = PluginCopyFiles.CopyTxtAndJsonFromRoot(sourcePluginDirectory, compiledPluginDirectory);
                var txtJsonDefaultFilesTask = PluginCopyFiles.CopyTxtAndJsonDefaultFiles(sourcePluginDirectory, compiledPluginDirectory);

                if (dependencyTasks != null)
                {
                    Task.WaitAll(dependencyTasks.ToArray());
                }

                var csProjFiles = sourcePluginDirectory
                                  .GetFiles("*.csproj", SearchOption.AllDirectories)
                                  .Where(f => f.Extension == ".csproj");
                foreach (var csProjFile in csProjFiles)
                {
                    pluginCompiler.CompilePlugin(
                        csProjFile,
                        compiledPluginDirectory.FullName,
                        new DirectoryInfo(rootDirectory)
                        );
                }

                var remainingTasks = new List <Task>();
                remainingTasks.AddRange(settingsTasks);
                remainingTasks.AddRange(staticFilesTasks);
                remainingTasks.AddRange(txtJsonFilesTask);
                remainingTasks.AddRange(txtJsonDefaultFilesTask);

                if (remainingTasks != null)
                {
                    Task.WaitAll(remainingTasks.ToArray());
                }
            }
            catch (Exception e)
            {
                DebugWindow.LogError($"PluginUpdater -> UpdateSinglePlugin \"{plugin.Name?.Value}\" failed.");
                DebugWindow.LogError($"PluginUpdater -> {e}");
            }

            var pluginWrapper = pluginLoader.Load(compiledPluginDirectory);

            return(pluginWrapper);
        }