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);
        }
Beispiel #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));
        }
Beispiel #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;
 }