static Expression InvokeMethodDummy( MethodBase mi, DynamicMetaObject target, DynamicMetaObject[] args, bool expandParameters, MethodInvocationType invocationType) { GetInstance().DummyFunc("InvokeMethodDummy"); return(null); }
// Original function receives a MethodBase (either a method or a constructor) and // builds an Expression object that calls it with supplied parameters. BabelShellfish // uses this behavior to add another call to its own inspection method before the // requested method is called. static Expression InvokeMethod( MethodBase mi, DynamicMetaObject target, DynamicMetaObject[] originalArgs, bool expandParameters, MethodInvocationType invocationType) { Expression exprOriginal = InvokeMethodDummy(mi, target, originalArgs, expandParameters, invocationType); if (GetInstance().BabelShellfishInspectInvoke.Count <= originalArgs.Length) { return(exprOriginal); } List <DynamicMetaObject> inspectArgs = new List <DynamicMetaObject>(); inspectArgs.Add(DynamicMetaObject.Create(mi, Expression.Constant(mi))); if (false == mi.IsStatic) { inspectArgs.Add(target); } for (int i = 0; i < originalArgs.Length; i++) { inspectArgs.Add(originalArgs[i]); } Expression exprInpect = InvokeMethodDummy( GetInstance().BabelShellfishInspectInvoke[inspectArgs.Count - 1], target, inspectArgs.ToArray(), expandParameters, MethodInvocationType.Ordinary); return(Expression.Block(exprInpect, exprOriginal)); }