From ff595e72f5fb6a6405bf768cd2af7e723cbf9eaf Mon Sep 17 00:00:00 2001 From: cinder Date: Wed, 15 Jan 2025 09:26:03 -0600 Subject: [PATCH] Add Count and Clear() to Inventory class. --- LibreMetaverse/Inventory.cs | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/LibreMetaverse/Inventory.cs b/LibreMetaverse/Inventory.cs index b2d06ac5..67adef2e 100644 --- a/LibreMetaverse/Inventory.cs +++ b/LibreMetaverse/Inventory.cs @@ -61,6 +61,7 @@ namespace OpenMetaverse /// public class Inventory { + #region EventHandlers /// The event subscribers, null if no subscribers private EventHandler m_InventoryObjectUpdated; @@ -129,7 +130,10 @@ namespace OpenMetaverse add { lock (m_InventoryObjectAddedLock) { m_InventoryObjectAdded += value; } } remove { lock (m_InventoryObjectAddedLock) { m_InventoryObjectAdded -= value; } } } - + #endregion EventHandlers + + #region Properties + /// /// The root folder of this avatars inventory /// @@ -166,8 +170,18 @@ namespace OpenMetaverse /// public InventoryNode LibraryRootNode { get; private set; } + /// + /// Returns owner of Inventory + /// public UUID Owner { get; } + /// + /// Returns number of stored entries + /// + public int Count => Items.Count; + + #endregion Properties + private GridClient Client; //private InventoryManager Manager; private ConcurrentDictionary Items; @@ -315,8 +329,7 @@ namespace OpenMetaverse } /// - /// Used to find out if Inventory contains the InventoryObject - /// specified by . + /// Check that Inventory contains the InventoryObject specified by . /// /// The UUID to check. /// true if inventory contains uuid, false otherwise @@ -325,11 +338,25 @@ namespace OpenMetaverse return Items.ContainsKey(uuid); } + /// + /// Check that Inventory contains the InventoryObject specified by . + /// + /// Object to check for + /// true if inventory contains object, false otherwise public bool Contains(InventoryBase obj) { return Contains(obj.UUID); } + /// + /// Clear all entries from Inventory store. + /// Useful for regenerating contents. + /// + public void Clear() + { + Items.Clear(); + } + /// /// Saves the current inventory structure to a cache file ///