Interface ISpecification<T>
- Namespace
- Framework.Patterns.Pure.Specification
- Assembly
- Assembly-CSharp.dll
조건 객체화 인터페이스. Framework 공식 조건 검증 방식. And/Or/Not 조합으로 복잡한 조건을 표현한다.
public interface ISpecification<T>
Type Parameters
T
- Extension Methods
Examples
// 단일 Specification
public sealed class AliveSpecification : ISpecification<Player>
{
public bool IsSatisfiedBy(Player player) => player.Hp > 0;
}
// 조합
var canAttack = aliveSpec.And(hasWeaponSpec).And(notStunnedSpec);
if (canAttack.IsSatisfiedBy(player)) Attack();
Remarks
[규칙] 구현체는 무상태(stateless)여야 한다. [규칙] 조건 조합은 SpecificationExtensions(.And/.Or/.Not)으로 처리한다. [규칙] Rule 패턴을 새로 만들지 않는다. 반드시 이 인터페이스를 사용한다.
Methods
IsSatisfiedBy(T)
대상이 조건을 만족하는지 평가한다.
bool IsSatisfiedBy(T target)
Parameters
targetT
Returns
- bool