/// <summary> /// 初始化插件 /// </summary> /// <param name="pluginInfo"></param> private void InitPlugin(PluginInfo pluginInfo) { var key = pluginInfo.Name; if (!_plugins.ContainsKey(key)) { pluginInfo.Plugin.Initialize(); _plugins.TryAdd(key, pluginInfo); } }
/// <summary> /// 卸载插件 /// </summary> /// <param name="pluginInfo"></param> public void UnloadPlugin(PluginInfo pluginInfo) { var key = pluginInfo.Name; PluginInfo plugin; _plugins.TryRemove(key, out plugin); foreach (var item in _areaPlugins.Where(p => pluginInfo.Areas.Values.Contains(p.Key))) { _areaPlugins.TryRemove(item.Key, out plugin); } File.Delete(pluginInfo.Path); }