초기커밋
This commit is contained in:
28
BrokerApiCore/Entity/Helpers/EntityExtensions.cs
Normal file
28
BrokerApiCore/Entity/Helpers/EntityExtensions.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
namespace BrokerCore.Entity;
|
||||
|
||||
using ServerCommon;
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user