Esempio n. 1
0
        internal static bool InternalGetInfoFromMember <T>(object target, string memberName, bool checkElementType, out MightyInfo <T> info)
        {
            var callbackSignature = new CallbackSignature(typeof(T), checkElementType);

            var fieldInfo = ReflectionUtilities.GetField(target.GetType(), memberName);

            if (callbackSignature.IsFieldValid(fieldInfo))
            {
                info = new MightyInfo <T>(target, fieldInfo, (T)fieldInfo.GetValue(target));
                return(true);
            }

            var propertyInfo = ReflectionUtilities.GetProperty(target.GetType(), memberName);

            if (callbackSignature.IsPropertyValid(propertyInfo))
            {
                info = new MightyInfo <T>(target, propertyInfo, (T)propertyInfo.GetValue(target));
                return(true);
            }

            var methodInfo = ReflectionUtilities.GetMethod(target.GetType(), memberName);

            if (callbackSignature.IsMethodValid(methodInfo))
            {
                info = new MightyInfo <T>(target, methodInfo, (T)methodInfo.Invoke(target, null));
                return(true);
            }

            info = null;
            return(false);
        }
Esempio n. 2
0
        private static bool InternalGetMightyVoidMethod(object target, string memberName, CallbackSignature callbackSignature,
                                                        out MightyVoidMethod method)
        {
            var methodInfo = ReflectionUtilities.GetMethod(target.GetType(), memberName);

            if (callbackSignature.IsMethodValid(methodInfo))
            {
                method = new MightyVoidMethod(target, methodInfo);
                return(true);
            }

            method = null;
            return(false);
        }