초기커밋
This commit is contained in:
146
ServerCommon/Entity/Attribute/PartyInvitePartySendsAttribute.cs
Normal file
146
ServerCommon/Entity/Attribute/PartyInvitePartySendsAttribute.cs
Normal file
@@ -0,0 +1,146 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public class PartyInvitePartySendsAttribute : EntityAttributeBase, ICopyEntityAttributeFromCache
|
||||
{
|
||||
private ConcurrentDictionary<string, DateTime> m_party_invite_party_sends { get; set; } = new();
|
||||
|
||||
public PartyInvitePartySendsAttribute(EntityBase owner) : base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override async Task<Result> onInit() => await Task.FromResult(new Result());
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
m_party_invite_party_sends.Clear();
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new PartyInvitePartySendsAttribute(getOwner());
|
||||
|
||||
foreach (var send in m_party_invite_party_sends)
|
||||
{
|
||||
cloned.m_party_invite_party_sends.TryAdd(send.Key, send.Value);
|
||||
}
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public ConcurrentDictionary<string, DateTime> getPartyInvitePartySends() => m_party_invite_party_sends;
|
||||
|
||||
public void addInvitePartySends(IReadOnlyList<string> add_sends)
|
||||
{
|
||||
foreach (var send in add_sends)
|
||||
{
|
||||
m_party_invite_party_sends[send] = DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteInvitePartySends(IReadOnlyList<string> delete_sends)
|
||||
{
|
||||
foreach (var send in delete_sends)
|
||||
{
|
||||
m_party_invite_party_sends.Remove(send, out _);
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteInvitePartySend(string invitee_guid)
|
||||
{
|
||||
m_party_invite_party_sends.Remove(invitee_guid, out _);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromCache(CacheBase? cacheBase)
|
||||
{
|
||||
var party_invite_party_send_cache = cacheBase as PartyInvitePartySendCache;
|
||||
if(null == party_invite_party_send_cache)
|
||||
{
|
||||
var err_msg = $"Failed to copyEntityAttributeFromCache() !!!, party_invite_party_send_cache is null :{nameof(PartyInvitePartySendCache)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Cache => Attribute
|
||||
//=====================================================================================
|
||||
m_party_invite_party_sends.Clear();
|
||||
foreach (var send in party_invite_party_send_cache.PartyInvitePartySends)
|
||||
{
|
||||
m_party_invite_party_sends.TryAdd(send.Key, send.Value);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromAttribute(PartyInvitePartySendsAttribute from_attribute)
|
||||
{
|
||||
//=====================================================================================
|
||||
// Attribute => Attribute
|
||||
//=====================================================================================
|
||||
m_party_invite_party_sends.Clear();
|
||||
foreach (var send in from_attribute.getPartyInvitePartySends())
|
||||
{
|
||||
m_party_invite_party_sends.TryAdd(send.Key, send.Value);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new PartyInvitePartySendsAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
return (new Result(), null);
|
||||
}
|
||||
}
|
||||
|
||||
public class PartyInvitePartySendsAttributeTransactor : EntityAttributeTransactorBase<PartyInvitePartySendsAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public PartyInvitePartySendsAttributeTransactor(EntityBase owner) : base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase entityAttributeBase)
|
||||
{
|
||||
string err_msg;
|
||||
|
||||
var copy_from_party_invite_party_send_attribute = entityAttributeBase as PartyInvitePartySendsAttribute;
|
||||
if (null == copy_from_party_invite_party_send_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_party_invite_party_send_attribute is null :{nameof(PartyInvitePartySendsAttribute)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_party_invite_party_send_attribute = getClonedEntityAttribute() as PartyInvitePartySendsAttribute;
|
||||
if (null == copy_to_party_invite_party_send_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_party_invite_party_send_attribute is null :{nameof(PartyInvitePartySendsAttribute)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_party_invite_party_send_attribute.copyEntityAttributeFromAttribute(copy_from_party_invite_party_send_attribute);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user