Пример #1
0
        public static Delegate CreateDelegateWrapper(MethodInfo wrappedMethod, object owner, Type funcOrActionType, bool isAction)
        {
            var        methodWrapper    = new MethodWrapper(wrappedMethod, owner);
            var        genericArguments = funcOrActionType.GetGenericArguments();
            MethodInfo wrapMethod;

            if (isAction)
            {
                if (genericArguments.Length == 0)
                {
                    wrapMethod = ActionFuncs[0];
                }
                else
                {
                    wrapMethod = ActionFuncs[genericArguments.Length].MakeGenericMethod(genericArguments);
                }
            }
            else
            {
                wrapMethod = WrapFuncs[genericArguments.Length - 1].MakeGenericMethod(genericArguments);
            }
            return(Delegate.CreateDelegate(funcOrActionType, methodWrapper, wrapMethod));
        }
Пример #2
0
 protected override object GetPropertyValue(ReflectObjectProperties wrapper, object reflectedObject)
 {
     return(MethodWrapper.CreateDelegateWrapper(reflectedMember, reflectedObject, ownProperty.PropertyType, isAction));
 }