private void StartExtensions() { if (PluginRegistry == null || PluginRegistry.Count == 0) { Log.Info("No plugins loaded, skipping initalization."); return; } Log.Info("Initializing extensions..."); for (var i = 0; i < PluginRegistry.Count; i++) { var pluginHost = PluginRegistry[i]; try { var pluginInfo = PluginRegistry.GetPluginInfoByName(pluginHost.Manifest.FriendlyName); var isLastPlugin = (i == PluginRegistry.Count - 1); pluginHost.Instance.Initialize(this, pluginHost.Manifest.IPCIdentifier); PluginInitialized?.Invoke(this, new PluginInitializationEventArgs(pluginInfo, isLastPlugin)); Log.Info($"Plugin {pluginHost.Manifest.FriendlyName} initialized"); } catch (Exception ex) { Log.Error($"Plugin {pluginHost.Manifest.FriendlyName} failed to initialize. Exception has been caught, see the log for details."); Log.ExceptionSilent(ex); } } Log.Info("Extensions initialized."); }
public async ValueTask Initialize(IPlugin plugin) { if (PluginStatus.ContainsKey(plugin) && !PluginStatus[plugin]) { await plugin.Initialize(PluginScopes[plugin]); PluginStatus[plugin] = true; var pluginDesciptorAttr = plugin.GetType().GetCustomAttribute <EmberPluginAttribute>(); PluginInitialized?.Invoke(PluginDescriptor.FromAttribute(pluginDesciptorAttr)); } }