Table of Contents

Interface IRuleEvaluator

Namespace
Framework.Common.Rules
Assembly
Assembly-CSharp.dll

Specification 패턴 기반 조건 평가 중앙화 계약.

public interface IRuleEvaluator

Examples

_ruleEvaluator.Register("canAttack", lowHpSpec.And(nearPlayerSpec));
bool result = _ruleEvaluator.Evaluate("canAttack", enemy);

Remarks

분산된 if/else 조건을 하나의 시스템에 등록하고 재사용 가능하게 한다. 조건 조합은 SpecificationExtensions(.And/.Or/.Not)으로 처리.

Methods

Evaluate<T>(string, T)

등록된 규칙으로 대상 평가.

bool Evaluate<T>(string ruleId, T target)

Parameters

ruleId string

평가할 규칙 키. 미등록 시 false 반환.

target T

평가할 대상.

Returns

bool

조건 만족 여부. 미등록 ruleId면 false.

Type Parameters

T

평가 대상 타입.

Register<T>(string, ISpecification<T>)

규칙 등록. 동일 ruleId 존재 시 덮어쓴다.

void Register<T>(string ruleId, ISpecification<T> spec)

Parameters

ruleId string

규칙 식별 키.

spec ISpecification<T>

평가에 사용할 Specification.

Type Parameters

T

평가 대상 타입.