Files
Umbraco-CMS/src/Umbraco.Core/ExpressionExtensions.cs
Shannon Deminick 5213d6de5c renamed IContentStore to IPublishedContentStore. Migrating DynamicNode to Umbraco.Core and cleaning up it's supported codebase.
Starting writing a few unit tests for the new DynamicNode codebase. Will of course leave the original DynamicNode stuff in its
current place for backwards compatibility but will deprecate many of the classes which will call the new ones.
2012-08-17 04:27:47 +06:00

28 lines
1.0 KiB
C#

using System;
using System.Linq;
using System.Linq.Expressions;
namespace Umbraco.Core
{
internal static class ExpressionExtensions
{
public static Expression<Func<T, bool>> True<T>() { return f => true; }
public static Expression<Func<T, bool>> False<T>() { return f => false; }
public static Expression<Func<T, bool>> Or<T>(this Expression<Func<T, bool>> left,
Expression<Func<T, bool>> right)
{
var invokedExpr = Expression.Invoke(right, left.Parameters.Cast<Expression>());
return Expression.Lambda<Func<T, bool>>
(Expression.OrElse(left.Body, invokedExpr), left.Parameters);
}
public static Expression<Func<T, bool>> And<T>(this Expression<Func<T, bool>> left,
Expression<Func<T, bool>> right)
{
var invokedExpr = Expression.Invoke(right, left.Parameters.Cast<Expression>());
return Expression.Lambda<Func<T, bool>>
(Expression.AndAlso(left.Body, invokedExpr), left.Parameters);
}
}
}