private void InitCommandPlugins() { MethodInfo[] methods = this.pluginType.GetMethods(); foreach (MethodInfo info in methods) { CommandPluginAttribute attribute = info.GetCustomAttributes(typeof(CommandPluginAttribute), false).FirstOrDefault <object>() as CommandPluginAttribute; if (attribute != null) { this.SureCommandHandler(attribute.ButtonName).Add(attribute, info); } } }
public void Add(CommandPluginAttribute plugin_attr, MethodInfo method_info) { CommandPluginHandler item = new CommandPluginHandler(this, plugin_attr, method_info); if (plugin_attr.InvokeType == InvokeType.Before) { this.beforeActions.Add(item); } else { this.afterActions.Add(item); } }
public CommandPluginHandler(CommandHandler _commandHandler, CommandPluginAttribute _pluginAttribute, MethodInfo _methodInfo) { if (_commandHandler == null) { throw new ArgumentNullException("_commandHandler"); } if (_pluginAttribute == null) { throw new ArgumentNullException("_pluginAttribute"); } if (_methodInfo == null) { throw new ArgumentNullException("_methodInfo"); } if (_commandHandler.pageHandler.pluginType != _methodInfo.ReflectedType) { throw new ArgumentNullException("_commandHandler.pageHandler.pluginType != _methodInfo.ReflectedType"); } this.commandHandler = _commandHandler; this.pluginAttribute = _pluginAttribute; this.methodInfo = _methodInfo; }