public static void InvokeBeforePlugins(object sender, PluginEventArgs e) { if (sender == null) { throw new ArgumentNullException("sender"); } if (e == null) { throw new ArgumentNullException("e"); } Control ctrl = sender as Control; if (ctrl == null) { throw new ApplicationExceptionFormat("传的sender {0}不是服务器控件", new object[] { sender.ToString() }); } Page absolutePage = ctrl.GetAbsolutePage(); IBasePage page2 = absolutePage as IBasePage; if (page2 == null) { throw new ApplicationExceptionFormat("页面不是继承自BasePage", new object[0]); } IPagePlugin pluginInstance = page2.PluginInstance; if (pluginInstance != null) { CommandHandler commandPluginHandler = GetCommandPluginHandler(ctrl); if (commandPluginHandler != null) { commandPluginHandler.ExecuteBefore(pluginInstance, ctrl, e); } } EventCallHelper.InvokeBefore(absolutePage, ctrl, new object[] { e.entityModel, e.RedirectURL, e.CurrentUserID }); }
private void InvokePluginList(IPagePlugin pluginInstance, List <CommandPluginHandler> plugin_handlers, Control sender, PluginEventArgs e) { if (plugin_handlers.Count > 0) { foreach (CommandPluginHandler handler in plugin_handlers) { handler.GetEventHandler(pluginInstance)(sender, e); } } }
public PluginEventHandler GetEventHandler(IPagePlugin pluginInstance) { PagePluginHandler pageHandler = this.commandHandler.pageHandler; if (pageHandler.pluginAttribute.Reusable) { IPagePlugin target = pageHandler.GetPluginInstance(); return(this.CreateEventHandler(target, this.methodInfo)); } return(this.CreateEventHandler(pluginInstance, this.methodInfo)); }
public PluginType_Metadata(Type type) { this.FullName = type.FullName; this.BaseType = type.BaseType; this.Assembly = type.Assembly; if (typeof(IPagePlugin).IsAssignableFrom(type)) { IPagePlugin pagePlugin = (IPagePlugin)Activator.CreateInstance(type); this.Description = pagePlugin.Description; } }
public static PageInfo GetPageInfo(IPagePlugin pagePlugin) { return(new PageInfo() { IsPlugin = true, CustomPageTypeName = pagePlugin.GetType().AssemblyQualifiedName, Items = pagePlugin.GetItems(), SubTitle = pagePlugin.SubTitle, Title = pagePlugin.Title, Privoder = pagePlugin.Privoder, Editable = false }); }
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(); }
public static IPagePlugin GetPlugin(Page page) { string pagePluginKey = GetPagePluginKey(page); if (pluginHandlers.ContainsKey(pagePluginKey)) { PagePluginHandler handler = pluginHandlers[pagePluginKey]; if (handler.pluginAttribute.Reusable) { return(handler.GetPluginInstance()); } IPagePlugin plugin = Activator.CreateInstance(handler.pluginType) as IPagePlugin; if (plugin == null) { throw new ApplicationExceptionFormat("创建页面{0}插件{1}的实例失败", new object[] { handler.pluginAttribute.PageName, handler.pluginType }); } return(plugin); } return(null); }
public void ExecuteBefore(IPagePlugin pluginInstance, Control sender, PluginEventArgs e) { this.InvokePluginList(pluginInstance, this.beforeActions, sender, e); }
public void ExecuteAfter(IPagePlugin pluginInstance, Control sender, PluginEventArgs e) { this.InvokePluginList(pluginInstance, this.afterActions, sender, e); }