コード例 #1
0
 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());
 }
コード例 #2
0
 public MockMethod RetrieveMethod(MethodInfo mi)
 {
     foreach (MockMethod m in mms)
     {
         if (MockerUtils.AreAllCompatible(m.Method, mi))
         {
             return(m);
         }
     }
     throw new InvalidOperationException();
 }
コード例 #3
0
 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);
     }
 }
コード例 #4
0
 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);
 }