Updated IPrefetchable implementation utilizing AACache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal sealed class AAInventoryItemCache : IPrefetchable | |
{ | |
private Dictionary<int, InventoryItem> _InventoryItems = new Dictionary<int, InventoryItem>(); | |
public void Prefetch() | |
{ | |
_InventoryItems.Clear(); | |
foreach (InventoryItem item in AACache<InventoryItem>.SelectRecords()) | |
{ | |
_InventoryItems[item.InventoryID.Value] = item; | |
} | |
} | |
private Dictionary<int, InventoryItem> InventoryItems | |
{ | |
get | |
{ | |
return _InventoryItems; | |
} | |
} | |
public static InventoryItem GetInventoryItem(int inventoryID) | |
{ | |
AAInventoryItemCache cache = GetSlot(); | |
cache.InventoryItems.TryGetValue(inventoryID, out InventoryItem item); | |
return item; | |
} | |
public static AAInventoryItemCache GetSlot() | |
{ | |
return PXDatabase.GetSlot<AAInventoryItemCache>(typeof(AAInventoryItemCache).FullName, typeof(InventoryItem)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment