public BSIPAModCell(ModListController list, PluginLoader.PluginMetadata plugin) : base("", "", null) { Plugin = plugin; this.list = list; var thisWeakRef = new WeakReference <BSIPAModCell>(this); PluginManager.PluginDisableDelegate reflessDDel = null; reflessDDel = disableDel = (p, r) => PluginManager_PluginDisabled(p, r, thisWeakRef, reflessDDel); // some indirection to make it a weak link for GC PluginManager.PluginDisabled += reflessDDel; PluginManager.PluginEnableDelegate reflessEDel = null; reflessEDel = enableDel = (p, r) => PluginManager_PluginEnabled(p, r, thisWeakRef, reflessEDel); // some indirection to make it a weak link for GC PluginManager.PluginEnabled += reflessEDel; Update(propogate: false); }
private static void PluginManager_PluginEnabled(PluginLoader.PluginInfo plugin, bool needsRestart, WeakReference <BSIPAModCell> _self, PluginManager.PluginEnableDelegate ownDel) { if (!_self.TryGetTarget(out var self)) { PluginManager.PluginEnabled -= ownDel; return; } if (plugin.Metadata != self.Plugin) { return; } self.Update(true, needsRestart); }