System.Linq.Expressions.Expression.IsCompatible C# (CSharp) Méthode

IsCompatible() private static méthode

private static IsCompatible ( PropertyInfo pi, Expression args ) : bool
pi System.Reflection.PropertyInfo
args Expression
Résultat bool
        private static bool IsCompatible(PropertyInfo pi, Expression[] args)
        {
            MethodInfo mi = pi.GetGetMethod(nonPublic: true);
            ParameterInfo[] parms;
            if (mi != null)
            {
                parms = mi.GetParametersCached();
            }
            else
            {
                mi = pi.GetSetMethod(nonPublic: true);
                //The setter has an additional parameter for the value to set,
                //need to remove the last type to match the arguments.
                parms = mi.GetParametersCached().RemoveLast();
            }

            if (mi == null)
            {
                return false;
            }
            if (args == null)
            {
                return parms.Length == 0;
            }

            if (parms.Length != args.Length)
                return false;
            for (int i = 0; i < args.Length; i++)
            {
                if (args[i] == null) return false;
                if (!TypeUtils.AreReferenceAssignable(parms[i].ParameterType, args[i].Type))
                {
                    return false;
                }
            }
            return true;
        }

Same methods

Expression::IsCompatible ( MethodBase m, Expression arguments ) : bool
Expression