zoukankan      html  css  js  c++  java
  • 反射:InvokeMethod 活动调用多种方法的方法配置要点

    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());
            }

  • 相关阅读:
    斐波那契数列递归算法和非递归算法以及其时间复杂度分析
    Python为什么不需要swap(a, b)
    学习MySQL中遇到的问题(net start mysql; 服务名无效。 请键入 NET HELPMSG 2185 以获得更多的帮助)
    python 3以上版本使用pickle.load读取文件报UnicodeDecodeError: 'ascii' codec can't decode byte 0x8b in position 6
    Mysql 服务无法启动 服务没有报告任何错误
    Keras和tensorflow的区别
    简单易懂的softmax交叉熵损失函数求导
    Ajax 请求
    Ajax 新建对象
    jquery Ajax noConflict()
  • 原文地址:https://www.cnblogs.com/soundcode/p/1922291.html
Copyright © 2011-2022 走看看