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