private static void FindPagePlugin(Type plugin_type) { PagePluginAttribute attribute = plugin_type.GetCustomAttributes(typeof(PagePluginAttribute), false).FirstOrDefault <object>() as PagePluginAttribute; if ((attribute != null) && !string.IsNullOrWhiteSpace(attribute.PageName)) { string key = attribute.PageName.ToLower(); if (pluginHandlers.ContainsKey(key)) { Type pluginType = pluginHandlers[key].pluginType; throw new ApplicationExceptionFormat("页面{0}存在重复插件{1}和{2}", new object[] { attribute.PageName, plugin_type, pluginType }); } PagePluginHandler handler = new PagePluginHandler(attribute, plugin_type); pluginHandlers.Add(key, handler); } }
public PagePluginHandler(PagePluginAttribute plugin_attribute, Type plugin_type) { if (plugin_attribute == null) { throw new ArgumentNullException("plugin_attribute"); } if (plugin_type == null) { throw new ArgumentNullException("plugin_type"); } this.pluginAttribute = plugin_attribute; this.pluginType = plugin_type; if (plugin_attribute.Reusable) { this._pluginInstance = this.NewPagePluginInstance(); } this._commandHandlers = new Dictionary <string, CommandHandler>(); this.InitCommandPlugins(); }