| /trunk/src/Example/Remember.Model/Specification.cs r392 | /trunk/src/Example/Remember.Model/Specification.cs r393 | ||
| 1 | using System; | 1 | using System; |
|---|---|---|---|
| 2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
| 3 | using System.Linq; | 3 | using System.Linq; |
| 4 | using System.Text; | 4 | using System.Text; |
| 5 | 5 | ||
| 6 | namespace Remember.Model | 6 | namespace Remember.Model |
| 7 | { | 7 | { |
| 8 | public abstract class Specification<T> | 8 | public abstract class Specification<T> |
| 9 | where T : class | ||
| 10 | { | 9 | { |
| 11 | public bool IsSatisfiedBy(T candidate) | 10 | public bool IsSatisfiedBy(T candidate) |
| 12 | { | 11 | { |
| 13 | if (candidate == null) | 12 | return SatisfyingElementsFrom(new[] { candidate }).Any(); |
| 14 | throw new ArgumentNullException("candidate"); | ||
| 15 | |||
| 16 | return SatisfiersFrom(new[] { candidate }).Any(); | ||
| 17 | } | 13 | } |
| 18 | 14 | ||
| 19 | public IEnumerable<T> SatisfiersFrom(IEnumerable<T> candidates) | 15 | public IEnumerable<T> SatisfyingElementsFrom(IEnumerable<T> candidates) |
| 20 | { | 16 | { |
| 21 | if (candidates == null) | 17 | if (candidates == null) |
| 22 | throw new ArgumentNullException("candidates"); | 18 | throw new ArgumentNullException("candidates"); |
| 23 | 19 | ||
| 24 | return SatisfiersFrom(candidates.AsQueryable()); | 20 | return SatisfyingElementsFrom(candidates.AsQueryable()); |
| 25 | } | 21 | } |
| 26 | 22 | ||
| 27 | public abstract IQueryable<T> SatisfiersFrom(IQueryable<T> candidates); | 23 | public abstract IQueryable<T> SatisfyingElementsFrom(IQueryable<T> candidates); |
| 28 | } | 24 | } |
| 29 | } | 25 | } |