public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result) { if (currentAttribute != "" && rest_method.ContainsKey(currentAttribute)) { ExposedObjectHelper.InvokeBestMethod(args, m_object, rest_method[currentAttribute].GetMethod(binder.Name, args.Length), out result); return(true); } return(base.TryInvokeMember(binder, args, out result)); }
public object InvokeRestMethod(string method, object target, params object[] args) { object rtn = null; if (currentAttribute != "" && rest_method.ContainsKey(currentAttribute)) { ExposedObjectHelper.InvokeBestMethod(args, target, rest_method[currentAttribute].GetMethod(method, args.Length), out rtn); } else { } return(rtn); }
public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result) { // Get type args of the call Type[] typeArgs = ExposedObjectHelper.GetTypeArgs(binder); if (typeArgs != null && typeArgs.Length == 0) { typeArgs = null; } // // Try to call a non-generic instance method // if (typeArgs == null && m_instanceMethods.ContainsKey(binder.Name) && m_instanceMethods[binder.Name].ContainsKey(args.Length) && ExposedObjectHelper.InvokeBestMethod(args, m_object, m_instanceMethods[binder.Name][args.Length], out result)) { return(true); } // // Try to call a generic instance method // if (m_instanceMethods.ContainsKey(binder.Name) && m_instanceMethods[binder.Name].ContainsKey(args.Length)) { List <MethodInfo> methods = new List <MethodInfo>(); foreach (var method in m_genInstanceMethods[binder.Name][args.Length]) { if (method.GetGenericArguments().Length == typeArgs.Length) { methods.Add(method.MakeGenericMethod(typeArgs)); } } if (ExposedObjectHelper.InvokeBestMethod(args, m_object, methods, out result)) { return(true); } } result = null; return(false); }
protected override void DoProcess(GoBusiParameter p, GoBusiData d) { lock (lockobj) { if (!_method.ContainsKey(this.Name)) { _method.Add(this.Name, new Dictionary <string, MethodInfo>()); } if (_method[this.Name].Count <= 0) { var t = this.GetType(); var methods = t.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); foreach (var m in methods) { var parray = m.GetParameters(); if (parray.Length == 1 && (parray[0].ParameterType.FullName == typeof(LogicData).FullName)) { _method[this.Name].Add(m.Name.ToLower(), m); } } } } LogicData ld = new LogicData(); //添加querystring foreach (var s in p.WebParam.Domain(DomainKey.QUERY_STRING)) { ld.SetValue(s.Key, s.Value); } //添加postback数据 foreach (var s in p.WebParam.Domain(DomainKey.POST_DATA)) { ld.SetValue(s.Key, s.Value); } //添加上传的文件 foreach (var s in p.WebParam.Domain(DomainKey.UPDATE_FILE)) { ld.SetValue(s.Key, s.Value); } //传入的参数 foreach (var s in p.WebParam.Domain(DomainKey.INPUT_PARAMETER)) { ld.SetValue(s.Key, s.Value); } //自定义的参数 foreach (var s in p.WebParam.Domain(DomainKey.CUSTOMER_PARAMETER)) { ld.SetValue(s.Key, s.Value); } object result = null; p.CallAction = p.CallAction == "" ? "load" : p.CallAction; if (_method[Name].ContainsKey(p.CallAction.ToLower())) { if (!ExposedObjectHelper.TryInvoke(_method[Name][p.CallAction.ToLower()], this, new object[] { ld }, out result, true)) { throw new Exception($"方法{Name}.{p.CallAction}执行失败"); } } else { GlobalCommon.Logger.WriteLog(LoggerLevel.ERROR, $"{Name}的Logic缺少名为{p.CallAction}的方法,请在{Name}中定义{p.CallAction}方法"); } d.WebData.ResponseData = result; if (d.WebData.ContentType == GoResponseDataType.RazorView) { if (d.WebData.ResponseData == null) { d.WebData.ResponseData = FrameDLRObject.CreateInstance(); } if (d.WebData.MvcModuleData == null) { d.WebData.MvcModuleData = d.WebData.ResponseData; } } }