Statistics
| Branch: | Revision:

root / trunk / hammock / src / net35 / Hammock / Specifications / HammockSpecification.cs @ 0eea575a

History | View | Annotate | Download (973 Bytes)

1
namespace Hammock.Specifications
2
{
3
    public abstract class HammockSpecification<T> : ISpecification<T>
4
    {
5
        #region ISpecification<T> Members
6

    
7
        public abstract bool IsSatisfiedBy(T instance);
8

    
9
        public virtual ISpecification<T> And(ISpecification<T> other)
10
        {
11
            return new AndSpecification<T>(this, other);
12
        }
13

    
14
        public virtual ISpecification<T> Or(ISpecification<T> other)
15
        {
16
            return new OrSpecification<T>(this, other);
17
        }
18

    
19
        public virtual ISpecification<T> Not()
20
        {
21
            return new NotSpecification<T>(this);
22
        }
23

    
24
        #endregion
25

    
26
        public static ISpecification<T> operator &(HammockSpecification<T> one, ISpecification<T> other)
27
        {
28
            return one.And(other);
29
        }
30

    
31
        public static ISpecification<T> operator |(HammockSpecification<T> one, ISpecification<T> other)
32
        {
33
            return one.Or(other);
34
        }
35
    }
36
}