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));
        }
Beispiel #2
0
        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);
            }
        }
Beispiel #3
0
        private static CommandHandler GetCommandPluginHandler(Control sender)
        {
            if (sender == null)
            {
                throw new ArgumentNullException("sender");
            }
            string pagePluginKey = GetPagePluginKey(sender.GetAbsolutePage());

            if (pluginHandlers.ContainsKey(pagePluginKey))
            {
                PagePluginHandler handler = pluginHandlers[pagePluginKey];
                if (handler.CommandHandlers.ContainsKey(sender.ID))
                {
                    return(handler.CommandHandlers[sender.ID]);
                }
            }
            return(null);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
 public CommandHandler(PagePluginHandler _pageHandler)
 {
     this.pageHandler   = _pageHandler;
     this.beforeActions = new List <CommandPluginHandler>();
     this.afterActions  = new List <CommandPluginHandler>();
 }