42 lines
1.3 KiB
C#
42 lines
1.3 KiB
C#
|
|
using System;
|
|
using System.Linq.Expressions;
|
|
|
|
namespace MyCode.Project.Infrastructure
|
|
{
|
|
/// <summary>
|
|
/// Represents the specification which is represented by the corresponding
|
|
/// LINQ expression.
|
|
/// </summary>
|
|
/// <typeparam name="T">The type of the object to which the specification is applied.</typeparam>
|
|
internal sealed class ExpressionSpecification<T> : Specification<T>
|
|
{
|
|
#region Private Fields
|
|
private Expression<Func<T, bool>> expression;
|
|
#endregion
|
|
|
|
#region Ctor
|
|
/// <summary>
|
|
/// Initializes a new instance of <c>ExpressionSpecification<T></c> class.
|
|
/// </summary>
|
|
/// <param name="expression">The LINQ expression which represents the current
|
|
/// specification.</param>
|
|
public ExpressionSpecification(Expression<Func<T, bool>> expression)
|
|
{
|
|
this.expression = expression;
|
|
}
|
|
#endregion
|
|
|
|
#region Public Methods
|
|
/// <summary>
|
|
/// Gets the LINQ expression which represents the current specification.
|
|
/// </summary>
|
|
/// <returns>The LINQ expression.</returns>
|
|
public override Expression<Func<T, bool>> GetExpression()
|
|
{
|
|
return this.expression;
|
|
}
|
|
#endregion
|
|
}
|
|
}
|