Table of Contents

Namespace Framework.Patterns.Pure.Decorator

Classes

ServiceDecorator<T>

기존 서비스를 수정하지 않고 기능 추가하는 래퍼 추상 클래스. 로깅, 캐싱 등 횡단 관심사 처리. [규칙] abstract class — 직접 인스턴스화 금지. [규칙] Inner 서비스 직접 수정 금지 — 호출만 허용.

사용 예:

public class LoggingPlayerService : ServiceDecorator<IPlayerService>, IPlayerService
{
    private readonly ILogSystem _log;
    public LoggingPlayerService(IPlayerService inner, ILogSystem log) : base(inner)
        => _log = log;

    public void TakeDamage(int amount)
    {
        _log.Info($"[플레이어] 데미지 수신: {amount}");
        Inner.TakeDamage(amount);
    }
}