public override Delegate CreateDelegate(DeleLambda lambda) { CQ_Content content = lambda.content.Clone(); var pnames = lambda.paramNames; var expr = lambda.expr_func; Action <T, T1, T2> dele = (T param0, T1 param1, T2 param2) => { if (expr != null) { try { content.DepthAdd(); CQ_Value p0 = new CQ_Value(); p0.SetObject(typeof(T), param0); content.DefineAndSet(pnames[0], typeof(T), p0); CQ_Value p1 = new CQ_Value(); p1.SetObject(typeof(T1), param1); content.DefineAndSet(pnames[1], typeof(T1), p1); CQ_Value p2 = new CQ_Value(); p2.SetObject(typeof(T2), param2); content.DefineAndSet(pnames[2], typeof(T2), p2); expr.ComputeValue(content); content.DepthRemove(); } catch (Exception err) { string errinfo = "Dump Call lambda in:"; if (content.CallType != null) { errinfo += content.CallType.Name + "::"; } #if CQUARK_DEBUG if (content.function != null) { errinfo += content.function; } #endif errinfo += "\n"; DebugUtil.Log(errinfo + content.Dump()); throw err; } } }; Delegate d = dele as Delegate; if ((Type)this.typeBridge != typeof(Action <T, T1, T2>)) { return(Delegate.CreateDelegate(this.typeBridge, d.Target, d.Method)); } else { return(dele); } }
public override Delegate CreateDelegate(DeleLambda lambda) { CQ_Content content = lambda.content.Clone(); var pnames = lambda.paramNames; var expr = lambda.expr_func; NonVoidDelegate dele = delegate(T param0, T1 param1) { if (expr != null) { try { content.DepthAdd(); CQ_Value p0 = new CQ_Value(); p0.SetObject(typeof(T), param0); content.DefineAndSet(pnames[0], typeof(T), p0); CQ_Value p1 = new CQ_Value(); p1.SetObject(typeof(T1), param1); content.DefineAndSet(pnames[1], typeof(T1), p1); CQ_Value retValue = expr.ComputeValue(content); content.DepthRemove(); return((ReturnType)retValue.GetObject()); } catch (Exception err) { string errinfo = "Dump Call lambda in:"; if (content.CallType != null) { errinfo += content.CallType.Name + "::"; } #if CQUARK_DEBUG if (content.function != null) { errinfo += content.function; } #endif errinfo += "\n"; DebugUtil.Log(errinfo + content.Dump()); throw err; } } return(default(ReturnType)); }; Delegate d = dele as Delegate; return(Delegate.CreateDelegate(this.typeBridge, d.Target, d.Method)); }
public override Delegate CreateDelegate(DeleLambda lambda) { CQ_Content content = lambda.content.Clone(); //var pnames = lambda.paramNames; var expr = lambda.expr_func; Action dele = () => { if (expr != null) { try { content.DepthAdd(); //content.DefineAndSet(pnames[0], typeof(T), param0); expr.ComputeValue(content); content.DepthRemove(); } catch (Exception) { string errinfo = "Dump Call lambda in:"; if (content.CallType != null) { errinfo += content.CallType.Name + "::"; } #if CQUARK_DEBUG if (content.function != null) { errinfo += content.function; } #endif errinfo += "\n"; DebugUtil.Log(errinfo + content.Dump()); } } }; Delegate d = dele as Delegate; if ((Type)this.typeBridge != typeof(Action)) { return(Delegate.CreateDelegate(this.typeBridge, d.Target, d.Method)); } else { return(dele); } }
public CQ_Value ComputeValue(CQ_Content content) { #if CQUARK_DEBUG content.InStack(this); #endif //List<CQ_Content.Value> list = new List<CQ_Content.Value>(); CQ_Value value = new CQ_Value(); DeleLambda dele = new DeleLambda(content, (this._expressions[0] as CQ_Expression_Block)._expressions, this._expressions[1]); value.SetObject(typeof(DeleLambda), dele); #if CQUARK_DEBUG content.OutStack(this); #endif return(value); }
public Delegate CreateDelegate(ICQ_Environment env, DeleLambda lambda) { CQ_Content content = lambda.content.Clone(); var pnames = lambda.paramNames; var expr = lambda.expr_func; Action <T> dele = (T param0) => { if (expr != null) { try { content.DepthAdd(); content.DefineAndSet(pnames[0], typeof(T), param0); expr.ComputeValue(content); content.DepthRemove(); } catch (Exception err) { string errinfo = "Dump Call lambda in:"; if (content.CallType != null) { errinfo += content.CallType.Name + "::"; } if (content.function != null) { errinfo += content.function; } errinfo += "\n"; env.logger.Log(errinfo + content.Dump()); throw err; } } }; Delegate d = dele as Delegate; if ((Type)this.type != typeof(Action <T>)) { return(Delegate.CreateDelegate(this.type, d.Target, d.Method)); } else { return(dele); } }
public Delegate CreateDelegate(ICQ_Environment env, DeleLambda lambda) { CQ_Content content = lambda.content.Clone(); var pnames = lambda.paramNames; var expr = lambda.expr_func; NonVoidDelegate dele = delegate(T param0, T1 param1) { if (expr != null) { try { content.DepthAdd(); content.DefineAndSet(pnames[0], typeof(T), param0); content.DefineAndSet(pnames[1], typeof(T1), param1); CQ_Content.Value retValue = expr.ComputeValue(content); content.DepthRemove(); return((ReturnType)retValue.value); } catch (Exception err) { string errinfo = "Dump Call lambda in:"; if (content.CallType != null) { errinfo += content.CallType.Name + "::"; } if (content.function != null) { errinfo += content.function; } errinfo += "\n"; env.logger.Log(errinfo + content.Dump()); throw err; } } return(default(ReturnType)); }; Delegate d = dele as Delegate; return(Delegate.CreateDelegate(this.type, d.Target, d.Method)); }
public override Delegate CreateDelegate(DeleLambda lambda) { CQ_Content content = lambda.content.Clone(); //var pnames = lambda.paramNames; var expr = lambda.expr_func; NonVoidDelegate dele = delegate() { if (expr != null) { try { content.DepthAdd(); CQ_Value retValue = expr.ComputeValue(content); content.DepthRemove(); return((ReturnType)retValue.value); } catch (Exception err) { string errinfo = "Dump Call lambda in:"; if (content.CallType != null) { errinfo += content.CallType.Name + "::"; } #if CQUARK_DEBUG if (content.function != null) { errinfo += content.function; } #endif errinfo += "\n"; DebugUtil.Log(errinfo + content.Dump()); throw err; } } return(default(ReturnType)); }; Delegate d = dele; return(Delegate.CreateDelegate(this.typeBridge, d.Target, d.Method)); }
public virtual Delegate CreateDelegate(DeleLambda lambda) { throw new Exception("方法没有被重载"); }