public void TestToStaticAction() { var foo = GetType().GetMethod("Foo"); var act = MethodInfoUtil.ToStaticAction <int>(foo); act(10); }
public void Invoke(object target, MethodInfo method, object arg) { IActionInvoker invoker; if (!_methodToActionInvoker.TryGetValue(method, out invoker)) { invoker = MethodInfoUtil.ToActionInvoker(method); _methodToActionInvoker[method] = invoker; } invoker.Invoke(target, arg); }
// ======================================== // method // ======================================== public PropertyInfo GetPropertyInfo(MethodInfo method) { PropertyInfo ret; if (!_MethodToPropMap.TryGetValue(method, out ret)) { if (MethodInfoUtil.IsPropertyGetter(method)) { ret = MethodInfoUtil.GetPropertyForGetter(method); _MethodToPropMap.Add(method, ret); } else if (MethodInfoUtil.IsPropertySetter(method)) { ret = MethodInfoUtil.GetPropertyForSetter(method); _MethodToPropMap.Add(method, ret); } else { _MethodToPropMap.Add(method, null); } } return(ret); }