I have two expressions:
public static Expression<Func<int, bool>> IsDivisibleByFive() {
   return (x) => x % 5 == 0;
}
and
public static Expression<Func<int, bool>> StartsWithOne() {
   return (x) => x.ToString().StartsWith("1");
}
And I want to create a new expression that applies both at once (the same expressions are used all over my code in different combinations):
public static Expression<Func<int, bool>> IsValidExpression() {
   return (x) => IsDivisibleByFive(x) && StartsWithOne(x);
}
Then do:
public static class IntegerExtensions
{
    public static bool IsValid(this int self) 
    {
        return IsValidExpression().Compile()(self);
    }
}
And in my code:
if (32.IsValid()) {
   //do something
}
I have many such expressions that I want to define once instead of duplicating code all over the place.
Thanks.
 
    