using System;
using System.Linq.Expressions;
namespace MyCode.Project.Infrastructure
{
///
/// Represents that the implemented classes are specifications. For more
/// information about the specification pattern, please refer to
/// http://martinfowler.com/apsupp/spec.pdf.
///
/// The type of the object to which the specification
/// is applied.
public interface ISpecification
{
///
/// Returns a value which indicates whether the specification
/// is satisfied by the given object.
///
/// The object to which the specification is applied.
/// True if the specification is satisfied, otherwise false.
bool IsSatisfiedBy(T obj);
///
/// Combines the current specification instance with another specification instance
/// and returns the combined specification which represents that both the current and
/// the given specification must be satisfied by the given object.
///
/// The specification instance with which the current specification
/// is combined.
/// The combined specification instance.
ISpecification And(ISpecification other);
///
/// Combines the current specification instance with another specification instance
/// and returns the combined specification which represents that either the current or
/// the given specification should be satisfied by the given object.
///
/// The specification instance with which the current specification
/// is combined.
/// The combined specification instance.
ISpecification Or(ISpecification other);
///
/// Combines the current specification instance with another specification instance
/// and returns the combined specification which represents that the current specification
/// should be satisfied by the given object but the specified specification should not.
///
/// The specification instance with which the current specification
/// is combined.
/// The combined specification instance.
ISpecification AndNot(ISpecification other);
///
/// Reverses the current specification instance and returns a specification which represents
/// the semantics opposite to the current specification.
///
/// The reversed specification instance.
ISpecification Not();
///
/// Gets the LINQ expression which represents the current specification.
///
/// The LINQ expression.
Expression> GetExpression();
}
}