/// <summary> /// 获取插件 /// </summary> /// <param name="key"></param> /// <returns></returns> public static T GetCurrentPlugin <T>(string key) { IComponentManger plugin = null; plugin = ComponentMangerProvider.GetPlugin(key); T pluginResult = (T)plugin; return(pluginResult); }
/// <summary> /// 获取插件 /// </summary> /// <param name="key"></param> /// <returns></returns> public static IComponentManger GetPlugin(string key) { Func <object> pluginConstructor = null; if (!PluginCollection.TryGetValue(key, out pluginConstructor)) { string otherKey = key; if (Headers.TryGetValue(key, out otherKey)) { PluginCollection.TryGetValue(otherKey, out pluginConstructor); } } IComponentManger plugin = null; if (pluginConstructor != null) { plugin = pluginConstructor() as IComponentManger; } if (plugin == null) { throw new Exception("未找到key对应的任何组件!"); } return(plugin); }