public static LambdaPropertyExpression FromLambdaExpression(object obj, LambdaExpression lambdaExpression, bool bindOnValidation)
        {
            if(lambdaExpression == null)
                throw new ArgumentNullException("lambdaExpression");

            var propertyExpressionParts = new List<PropertyExpressionPart>();
            var currentMemberExpression = DetermineMemberExpression(lambdaExpression, lambdaExpression.Body);
            MemberExpressionPropertyExpressionPart nextPart = null;

            while (currentMemberExpression != null)
            {
                var part = new MemberExpressionPropertyExpressionPart(nextPart, currentMemberExpression, bindOnValidation);
                nextPart = part;
                propertyExpressionParts.Insert(0, part);
                currentMemberExpression = currentMemberExpression.Expression as MemberExpression;
            }

            return new LambdaPropertyExpression(obj, propertyExpressionParts);
        }
Exemple #2
0
        public static LambdaPropertyExpression FromLambdaExpression(object obj, LambdaExpression lambdaExpression, bool bindOnValidation)
        {
            if (lambdaExpression == null)
            {
                throw new ArgumentNullException("lambdaExpression");
            }

            var propertyExpressionParts = new List <PropertyExpressionPart>();
            var currentMemberExpression = DetermineMemberExpression(lambdaExpression, lambdaExpression.Body);
            MemberExpressionPropertyExpressionPart nextPart = null;

            while (currentMemberExpression != null)
            {
                var part = new MemberExpressionPropertyExpressionPart(nextPart, currentMemberExpression, bindOnValidation);
                nextPart = part;
                propertyExpressionParts.Insert(0, part);
                currentMemberExpression = currentMemberExpression.Expression as MemberExpression;
            }

            return(new LambdaPropertyExpression(obj, propertyExpressionParts));
        }
Exemple #3
0
 public MemberExpressionPropertyExpressionPart(MemberExpressionPropertyExpressionPart nextPart, MemberExpression memberExpression, bool bindOnValidation)
     : base(nextPart, bindOnValidation)
 {
     Debug.Assert(memberExpression != null);
     _propertyInfo = memberExpression.Member as PropertyInfo;
 }
 public MemberExpressionPropertyExpressionPart(MemberExpressionPropertyExpressionPart nextPart, MemberExpression memberExpression, bool bindOnValidation)
     : base(nextPart, bindOnValidation)
 {
     Debug.Assert(memberExpression != null);
     _propertyInfo = memberExpression.Member as PropertyInfo;
 }