using System;
using System.Linq.Expressions;
namespace MyCode.Project.Infrastructure
{
///
/// Represents the specification which indicates the semantics opposite to the given specification.
///
/// The type of the object to which the specification is applied.
public class NotSpecification : Specification
{
#region Private Fields
private ISpecification spec;
#endregion
#region Ctor
///
/// Initializes a new instance of NotSpecification<T> class.
///
/// The specification to be reversed.
public NotSpecification(ISpecification specification)
{
this.spec = specification;
}
#endregion
#region Public Methods
///
/// Gets the LINQ expression which represents the current specification.
///
/// The LINQ expression.
public override Expression> GetExpression()
{
var body = Expression.Not(this.spec.GetExpression().Body);
return Expression.Lambda>(body, this.spec.GetExpression().Parameters);
}
#endregion
}
}