反射: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());
??????? }
總結
以上是生活随笔為你收集整理的反射:InvokeMethod 活动调用多种方法的方法配置要点的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SpaceX首次载人发射 正式通过飞
- 下一篇: WF:要想绑到两个活动的属性值---依赖