namespace BrokerApiCore; using ServerBase; using ServerCore; public static class EntityExtensions { public static TEntityAttributeBase getEntityAttributeNotNull(this EntityBase entity) where TEntityAttributeBase : EntityAttributeBase { TEntityAttributeBase? attribute = entity.getEntityAttribute(); // todo: 이렇게 널 처리를 하면 일관되게 처리할 수 있지만, null이 발생한 코드 위치가 항상 여기로 찍힌다. // getEntityAttributeNotNull를 호출한 위치에서 로그를 찍을 수 있는 지 고민해보자. NullReferenceCheckHelper.throwIfNull(attribute, () => $"entity attribute {nameof(TEntityAttributeBase)} not found - {entity.toBasicString()}"); return attribute; } public static TEntityActionBase getEntityActionNotNull(this EntityBase entity) where TEntityActionBase : EntityActionBase { TEntityActionBase? action = entity.getEntityAction(); NullReferenceCheckHelper.throwIfNull(action, () => $"entity action {nameof(TEntityActionBase)} not found - {entity.toBasicString()}"); return action; } }