public void Unregister(int id, AttachmentKey attachmentKey) { if (_attachmentKeys[id] == attachmentKey) { _attachmentKeys[id] = null; } }
public AttachmentKey Register(int id, AttachmentKey attachmentKey) { if (!attachmentKey.Applicable(this)) { throw new ArgumentException("Attachment key not applicable to this flavour"); } AttachmentKey rlt; if (_attachmentKeys.Count < id) { rlt = _attachmentKeys[id]; rlt?.Unregister(); _attachmentKeys[id] = attachmentKey; } else { id--; rlt = null; while (_attachmentKeys.Count < id) { _attachmentKeys.Add(null); } _attachmentKeys.Add(attachmentKey); } return(rlt); }
public LoadRequest(ResourceType type, IKeyed holder, AttachmentKey key, ResourceDomain domain, IResult result) { Type = type; _holder = new WeakReference <IKeyed>(holder); Key = key; Domain = domain; Result = result; }
public bool IsFree(int id, AttachmentKey attachmentKey) { if (_attachmentKeys.Count >= id) { return(true); } var current = _attachmentKeys[id]; // ReSharper disable once ArrangeRedundantParentheses return(current == null || (!current.IsUsed && current.CountFlovours < attachmentKey.CountFlovours)); }
public AsyncResult <T> LoadResource <T>(ResourceType <T> type, IKeyed holder, AttachmentKey key, ResourceDomain domain) { var result = new AsyncResult <T>(); var request = new LoadRequest(type, holder, key, domain, result); _loadRequests.Enqueue(request); return(result); }