private MethodInfo GetMethodFromTypes(object[] args) { return(methods.Where( m => MockerUtils.AreAllCompatible( m.GetParameters().Select(p => p.ParameterType).ToArray(), args.Select(a => a.GetType()).ToArray())).First()); }
public MockMethod RetrieveMethod(MethodInfo mi) { foreach (MockMethod m in mms) { if (MockerUtils.AreAllCompatible(m.Method, mi)) { return(m); } } throw new InvalidOperationException(); }
private void DefineInterfaceMethods(TypeBuilder tb, MethodInfo mi) { MockMethod[] mm = ms.Where(m => MockerUtils.AreAllCompatible(m.Method, mi)).ToArray(); if (mm.Count() > 0) { DefineMockMethod(tb, mm[0]); } else { DefineDefaultInterfaceMethodBehaviour(tb, mi); } }
private bool IsThereAnyMethodCompatibleWithDelegate(Type delType) { Type[] delParams = LazyQueries.Convert <ParameterInfo, Type>(delType.GetMethod("Invoke").GetParameters(), pi => pi.ParameterType).ToArray(); foreach (MethodInfo mi in methods) { Type[] methParams = mi.GetParameters().Select(p => p.ParameterType).ToArray(); if ((methParams.Length == 0 && delParams.Length == 0) || (MockerUtils.AreAllCompatible(methParams, delParams) && delType.GetMethod("Invoke").ReturnType == mi.ReturnType && this.Name.Equals(mi.Name))) { meth = mi; return(true); } } return(false); }