public static IMethod GetMethod(Type type, string methodName, Type[] parameters, BindingFlags flag = DefBindingFlags) { IMethod method; Locker.Lock(); var methodCurrentName = string.Concat(type.FullName, methodName, (parameters != null ? parameters.Length.ToString(CultureInfo.InvariantCulture) : string.Empty)); if (!Methods.TryGetValue(methodCurrentName, out method)) { var methodInfo = type.GetMethod(methodName, flag, null, parameters, null); if (methodInfo != null) { if (!Methods.ContainsKey(methodCurrentName)) { method = new MethodImplement(methodInfo); Methods.Add(methodCurrentName, method); } else { method = Methods[methodCurrentName]; } } } Locker.Unlock(); return(method); }
public static IMethod GetMethodWithoutCache(MethodInfo methodInfo) { IMethod m = null; try { m = new MethodImplement(methodInfo); } catch (Exception ex) { Debug.WriteLine(ex); } return(m); }