internal static LambdaExpression TryToRewrite(LambdaExpression le, ResourceExpression source) { Type proposedParameterType = source.ResourceType; if ((!ResourceBinder.PatternRules.MatchSingleArgumentLambda(le, out le) || ClientTypeUtil.TypeOrElementTypeIsEntity(le.Parameters[0].Type)) || !le.Parameters[0].Type.GetProperties().Any<PropertyInfo>(p => (p.PropertyType == proposedParameterType))) { return le; } ProjectionRewriter rewriter = new ProjectionRewriter(proposedParameterType); return rewriter.Rebind(le, source); }
internal static LambdaExpression TryToRewrite(LambdaExpression le, ResourceExpression source) { Type proposedParameterType = source.ResourceType; if ((!ResourceBinder.PatternRules.MatchSingleArgumentLambda(le, out le) || ClientTypeUtil.TypeOrElementTypeIsEntity(le.Parameters[0].Type)) || !le.Parameters[0].Type.GetProperties().Any <PropertyInfo>(p => (p.PropertyType == proposedParameterType))) { return(le); } ProjectionRewriter rewriter = new ProjectionRewriter(proposedParameterType); return(rewriter.Rebind(le, source)); }
internal static LambdaExpression TryToRewrite(LambdaExpression le, Type proposedParameterType) { LambdaExpression result; if (!ResourceBinder.PatternRules.MatchSingleArgumentLambda(le, out le) || ClientType.CheckElementTypeIsEntity(le.Parameters[0].Type) || !(le.Parameters[0].Type.GetProperties().Any(p => p.PropertyType == proposedParameterType))) { result = le; } else { ProjectionRewriter rewriter = new ProjectionRewriter(proposedParameterType); result = rewriter.Rebind(le); } return result; }
internal static LambdaExpression TryToRewrite(LambdaExpression le, Type proposedParameterType) { LambdaExpression result; if (!ResourceBinder.PatternRules.MatchSingleArgumentLambda(le, out le) || ClientType.CheckElementTypeIsEntity(le.Parameters[0].Type) || !(le.Parameters[0].Type.GetProperties().Any(p => p.PropertyType == proposedParameterType))) { result = le; } else { ProjectionRewriter rewriter = new ProjectionRewriter(proposedParameterType); result = rewriter.Rebind(le); } return(result); }
internal static LambdaExpression TryToRewrite(LambdaExpression le, Type proposedParameterType) { LambdaExpression result; if (!ResourceBinder.PatternRules.MatchSingleArgumentLambda(le, out le) || // can only rewrite single parameter Lambdas. ClientType.CheckElementTypeIsEntity(le.Parameters[0].Type) || // only attempt to rewrite if lambda parameter is not an entity type !(le.Parameters[0].Type.GetProperties().Any(p => p.PropertyType == proposedParameterType))) // lambda parameter must have public property that is same as proposed type. { result = le; } else { ProjectionRewriter rewriter = new ProjectionRewriter(proposedParameterType); result = rewriter.Rebind(le); } return result; }
internal static LambdaExpression TryToRewrite(LambdaExpression le, Type proposedParameterType) { LambdaExpression result; if (!ResourceBinder.PatternRules.MatchSingleArgumentLambda(le, out le) || // can only rewrite single parameter Lambdas. ClientType.CheckElementTypeIsEntity(le.Parameters[0].Type) || // only attempt to rewrite if lambda parameter is not an entity type !(le.Parameters[0].Type.GetProperties().Any(p => p.PropertyType == proposedParameterType))) // lambda parameter must have public property that is same as proposed type. { result = le; } else { ProjectionRewriter rewriter = new ProjectionRewriter(proposedParameterType); result = rewriter.Rebind(le); } return(result); }