public async Task <IActionResult> TestLoadPlugin() { var path = Path.Combine(pluginManagers.GetBasePluginsPath(), "Brochure.Authority", "plugin.config"); var p = await pluginLoader.LoadPlugin(path); if (!(p is Plugins plugin)) { return new ContentResult() { Content = "bbb" } } ; var startConfigs = reflectorUtil.GetObjectOfBase <IStarupConfigure>(plugin.Assembly); // var context = new PluginMiddleContext(app.ServiceProvider, plugin.Key); // plugin.Context.Services.Add(context); foreach (var item in startConfigs) { item.Configure(plugin.Key, applicationBuilder); } mvcBuilder.AddApplicationPart(plugin.Assembly); PluginActionDescriptorChangeProvider.Instance.HasChanged = true; PluginActionDescriptorChangeProvider.Instance.TokenSource.Cancel(); return(new ContentResult() { Content = "aaa" }); }
private void StartHost() { var processInfo = new ProcessStartInfo { Arguments = new TypedArgs(parentProcessId, PluginInfo.AssemblyFile, instanceName).ToArgs(), CreateNoWindow = true, // Note: The command window might be helpful to search for errors. UseShellExecute = false, FileName = "PluginHost.exe", WorkingDirectory = Path.GetDirectoryName(PluginInfo.AssemblyFile) }; using (var readyEvent = new EventWaitHandle(false, EventResetMode.ManualReset, instanceName + ".Ready")) { var pluginProcess = Process.Start(processInfo); pluginProcess.EnableRaisingEvents = true; pluginProcess.Exited += PluginProcessExited; if (!readyEvent.WaitOne(3000)) { throw new InvalidOperationException("Plugin host process not ready."); } } var url = "ipc://" + instanceName + "/PluginLoader"; pluginLoader = (IPluginLoader)Activator.GetObject(typeof(IPluginLoader), url); // TODO: This won't work if the plugin crashes during startup! var contract = pluginLoader.LoadPlugin(PluginInfo.AssemblyFile, PluginInfo.PluginControllerName); RemoteView = FrameworkElementAdapters.ContractToViewAdapter(contract); }
private async void WebClient_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { var automaticaPluginUpdateFile = Path.Combine(ServerInfo.GetTempPath(), ServerInfo.PluginUpdateDirectoryName, _plugin.AzureFileName); try { if (e.Error == null && !e.Cancelled) { await _updateHub.Clients.All.SendAsync("PluginFinished", new object[] { _plugin.PluginGuid }); if (_install) { if (await _api.InstallPlugin(_plugin, automaticaPluginUpdateFile)) { await _pluginLoader.LoadPlugin(_plugin); } } else { if (_restartOnUpdate) { _coreServer.Restart(); } } } } finally { if (_install && File.Exists(automaticaPluginUpdateFile)) { File.Delete(automaticaPluginUpdateFile); SystemLogger.Instance.LogDebug($"Remove update file for {_plugin.ComponentName}: {automaticaPluginUpdateFile}"); } } }
public void LoadPlugin() { if (Process == null) { throw new InvalidOperationException("Plugin process not started"); } if (Process.HasExited) { throw new InvalidOperationException("Plugin process has terminated unexpectedly"); } _pluginLoader = GetPluginLoader(); RemotePlugin = _pluginLoader.LoadPlugin(_host, _startupInfo); }
private async Task <Dictionary <int, IBattleshipsGame> > GetCompetitorsAsync(League league) { var players = (await playerRepository.GetAllPlayersAsync()) .Where(x => x.League == league) .ToDictionary(x => x.FileGuid); var competitors = new Dictionary <int, IBattleshipsGame>(); foreach (var player in players) { var pluginAssembly = pluginLoader.LoadPlugin(player.Key); var instance = pluginLoader.GetInstance(pluginAssembly); competitors.Add(player.Value.Id, instance); } return(competitors); }
private void LoadPlugin(FileInfo file) { PluginInfo info = Loader.GetPluginInfo(file); if (info != null) { YakitoriPlugin plugin = Loader.LoadPlugin(file, info); if (plugin != null) { Plugins.Add(info.PluginId, plugin); PluginInfoList.Add(info); plugin.enabled = true; Console.WriteLine("Successful load : " + file.Name); return; } } Console.Error.WriteLine("Failure to load : " + file.Name); }
public void LoadPlugin() { if (Process == null) throw new InvalidOperationException("Plugin process not started"); if (Process.HasExited) throw new InvalidOperationException("Plugin process has terminated unexpectedly"); _pluginLoader = GetPluginLoader(); RemotePlugin = _pluginLoader.LoadPlugin(_host, _startupInfo); }