예제 #1
0
        public async Task AddPlugin(string settingFile, List <ZipArchiveEntry> files)
        {
            var plugin = JsonConvert.DeserializeObject <Plugin>(settingFile);

            plugin.Valid = true;
            if (LoadedPlugins.Any())
            {
                plugin.Priority = LoadedPlugins.Max(x => x.Priority) + 1;
            }
            else
            {
                plugin.Priority = 1;
            }
            var loadeds = new List <Plugin>(LoadedPlugins);

            Directory.CreateDirectory($"plugins/{plugin.PluginPath}");
            plugin.IsEnabled = false;
            foreach (var file in files)
            {
                file.ExtractToFile(Path.Combine($"plugins/{plugin.PluginPath}", file.FullName), true);
            }
            PreCompilePlugin(plugin);
            loadeds.Add(plugin);
            LoadedPlugins = loadeds;
            await File.WriteAllTextAsync(PluginSettingPath, JsonConvert.SerializeObject(LoadedPlugins));
        }
 public bool ImportPlugin(string pluginPath)
 {
     if (LoadedPlugins.Any(p => p.FullName == pluginPath))
     {
         return(true);
     }
     else
     {
         var plugin = new FileInfo(pluginPath);
         LoadedPlugins.Add(plugin);
         return(PluginManager.AddPlugin(plugin));
     }
 }
예제 #3
0
 public Task <bool> ImportPlugin(string pluginPath)
 {
     if (LoadedPlugins.Any(p => p.FullName == pluginPath))
     {
         return(Task.FromResult(true));
     }
     else
     {
         var plugin = new FileInfo(pluginPath);
         LoadedPlugins.Add(plugin);
         return(Task.FromResult(PluginManager.AddPlugin(plugin)));
     }
 }