博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
反射:InvokeMethod 活动调用多种方法的方法配置要点
阅读量:7078 次
发布时间:2019-06-28

本文共 1524 字,大约阅读时间需要 5 分钟。

MethodName: 方法名称

TargetObject: 当调用方法不为静态的时候,需要新建调用方法类实例

TargetType: 当调用方法为静态的时候,需要指定调用方法类的类型

GenericTypeArguments: 若调用方法为静态方法,则在此泛型集合中指定。

Parameters: 在此集合中指定方法参数的值

Result: 在此指定方法返回值

 

---------------------------------------------------

private string Action="Add";

private string BaseMethodName = "Accident{0}";

 

protected void btnSubmit_Click(object sender, EventArgs e)

        {
            try 
            {
                string methodName = string.Format(BaseMethodName, Action);
                Type thisType = this.GetType();
                MethodInfo excuteMethod = thisType.GetMethod(methodName);
                excuteMethod.Invoke(this, null);
            }
            catch (Exception ex) 
            {
                MyLog.log.Warn(ex.Message);
                QueryScript.ErrorMessageShow(this.Page, "showerr", ex.Message);
            }
        }

        /// <summary>

        /// 添加一个事故
        /// </summary>
        /// <returns></returns>
        public void AccidentAdd() 
        {
            MySession mySession = new MySession(this.Page);
            BzAccidentEntity model = new BzAccidentEntity();
            model.DATE_HAPPENED = DateTime.Parse(txtDate.Text.ToString());
            model.TITLE = txtTitle.Text;
            model.TYPE_ID = Int32.Parse(txtType.SelectedValue.ToString());
            model.REASON = txtReason.Text;
            model.SUMMARY = txtSummary.Text;

            model.CREATE_MAN = mySession.getUserId();

            model.DATE_CREATED = DateTime.Now;
            model.ORGAN_ID = mySession.getOrganId();
            int i=accBLL.AddBzAccident(model);
            MyControlOption.ClearValue(this);
            txtDate.Text = DateTime.Now.ToString("yyyy-MM-dd");
            QueryScript.MessageShow(this.Page, "showSuc", MyPrompt.AccidentDicOptionInfo["success"].ToString());
        }

 

本文转自左正博客园博客,原文链接:http://www.cnblogs.com/soundcode/archive/2010/12/30/1922291.html,如需转载请自行联系原作者

你可能感兴趣的文章
从Web到未来
查看>>
JS-常用数组API、对象API与日期、随机数
查看>>
Nodejs操作MySQL-增删改查
查看>>
使用Docker搭建Squid代理服务器
查看>>
makefile规则
查看>>
【运维】nginx服务器基本配置指南
查看>>
Angular通过订阅观察者对象实现不同组件中数据的实时传递
查看>>
Bitmap的图片压缩汇总
查看>>
树莓派学习手记——制作一个空调遥控器(红外接收、发射的实现)
查看>>
《Maven实战》阅读总结(二)Maven仓库
查看>>
【369天】每日项目总结系列106(2018.02.09)
查看>>
WordPress 主题开发:从入门到精通(必读)
查看>>
Vue入坑记
查看>>
#ReactApp项目构建流程【3】
查看>>
canal 1.0.25 快速启动配置
查看>>
SpringBoot使用AOP+注解实现简单的权限验证
查看>>
Android 8.0 系统和API的变化
查看>>
Git 多人协作开发流程
查看>>
js 时间对象的常规操作
查看>>
BiuJS[v1.0]说明文档(2):数据劫持
查看>>