private void btnReload_Click(object sender, EventArgs e) { IAddon notifications = AddonManager.GetAddon("Notifications"); notifications.Dispose(); notifications.Initialize(); }
/// <summary> /// Reload an addon /// </summary> /// <param name="name"></param> /// <remarks>Reloading addons is highly discouraged! Only use if no other way is possible</remarks> public static void ReloadAddon(string name) { if (string.IsNullOrEmpty(name)) { return; } try { IAddon addon = GetAddon(name); if (addon == null) { return; } if (addon.HasTab) { return; // we can't reload these yet! } if (addon.HasTab && TabsDictionary.ContainsKey(addon)) { TabsDictionary.Remove(addon); } if (addon.HasConfig && SettingsDictionary.ContainsKey(addon)) { SettingsDictionary.Remove(addon); } Settings.Settings settingsmanager = ((Settings.Settings)GetRequiredAddon(RequiredAddon.Settings)); settingsmanager.RemoveAddonSettings(addon); //unload settings addon.Dispose(); //dispose old addon addon = CreateAddon(addon); // create new one + initialize settingsmanager.AddAddonSettings(addon); // load settings } catch (Exception exception) { Logger.Log(LogLevel.Severe, "AddonManager", "Failed to reload addon! " + name, exception.Message); } }