114 lines
3.3 KiB
C#
114 lines
3.3 KiB
C#
using System;
|
|
using System.Collections.Concurrent;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using ServerCore; using ServerBase;
|
|
|
|
|
|
using SESSION_ID = System.Int32;
|
|
using WORLD_ID = System.UInt32;
|
|
using META_ID = System.UInt32;
|
|
using ENTITY_GUID = System.String;
|
|
using ACCOUNT_ID = System.String;
|
|
using OWNER_GUID = System.String;
|
|
using USER_GUID = System.String;
|
|
using CHARACTER_GUID = System.String;
|
|
using ITEM_GUID = System.String;
|
|
|
|
|
|
|
|
namespace ServerBase;
|
|
|
|
public abstract partial class EntityAttributeTransactorBase<TEntityAttribute> : IEntityAttributeTransactor
|
|
where TEntityAttribute : EntityAttributeBase
|
|
{
|
|
public enum TransactionState
|
|
{
|
|
None = 0,
|
|
|
|
New, // 생성
|
|
Modify, // 변경
|
|
Remove, // 제거
|
|
|
|
Completed // 처리 완료
|
|
}
|
|
|
|
private EntityBase m_owner;
|
|
|
|
private TEntityAttribute? m_cloned_entity_attribute_nullable;
|
|
|
|
private TransactionState m_transaction_state = TransactionState.None;
|
|
|
|
private readonly EntityRecorder m_entity_recorder;
|
|
|
|
private TEntityAttribute? m_origin_entity_attribute_nullable;
|
|
|
|
|
|
public EntityAttributeTransactorBase(EntityBase owner)
|
|
{
|
|
m_owner = owner;
|
|
m_entity_recorder = new EntityRecorder(owner);
|
|
}
|
|
|
|
public bool cloneFromOriginEntityAttribute(EntityAttributeBase fromOriginEntityAttribute)
|
|
{
|
|
m_cloned_entity_attribute_nullable = fromOriginEntityAttribute.onCloned() as TEntityAttribute;
|
|
if(null == m_cloned_entity_attribute_nullable)
|
|
{
|
|
var err_msg = $"m_cloned_entity_attribute_nullable is null !!! : toCloneTarget:{typeof(TEntityAttribute).Name} != OriginEntityAttribute:{fromOriginEntityAttribute.getTypeName()} - {getOwner().toBasicString()}";
|
|
Log.getLogger().error(err_msg);
|
|
return false;
|
|
}
|
|
|
|
m_cloned_entity_attribute_nullable.setCloned();
|
|
m_cloned_entity_attribute_nullable.bindEntityRecorder(m_entity_recorder);
|
|
|
|
m_origin_entity_attribute_nullable = fromOriginEntityAttribute as TEntityAttribute;
|
|
|
|
return true;
|
|
}
|
|
|
|
public bool isReadOnly()
|
|
{
|
|
NullReferenceCheckHelper.throwIfNull(m_cloned_entity_attribute_nullable, () => $"m_cloned_entity_attribute_nullable is null !!! - {getOwner().toBasicString()}");
|
|
|
|
if(true == m_cloned_entity_attribute_nullable.getAttributeState().isEmptyFlags())
|
|
{
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public async Task<(Result, DynamoDbDocBase?)> makeDocBase()
|
|
{
|
|
NullReferenceCheckHelper.throwIfNull(m_cloned_entity_attribute_nullable, () => $"m_cloned_entity_attribute_nullable is null !!! - {getOwner().toBasicString()}");
|
|
|
|
(var result, var doc) = await m_cloned_entity_attribute_nullable.toDocBase();
|
|
if(result.isFail())
|
|
{
|
|
return (result, null);
|
|
}
|
|
|
|
return (result, doc);
|
|
}
|
|
|
|
public virtual void onClear()
|
|
{
|
|
m_cloned_entity_attribute_nullable?.onClear();
|
|
|
|
m_entity_recorder.reset();
|
|
}
|
|
|
|
public ENTITY_GUID getEntityGuid() => getOwner().getEntityGuid();
|
|
|
|
public virtual string toBasicString()
|
|
{
|
|
return $"{this.getTypeName()}, {m_cloned_entity_attribute_nullable?.toBasicString()}, {getOwner().toBasicString()}";
|
|
}
|
|
}
|