/// <summary> /// Pulls an object from the pool. /// </summary> /// <returns></returns> public static InventoryMessage Allocate(InventoryMessage rSource) { // Grab the next available object InventoryMessage lInstance = sPool.Allocate(); if (lInstance == null) { lInstance = new InventoryMessage(); } lInstance.InventorySource = rSource.InventorySource; lInstance.ItemID = rSource.ItemID; lInstance.SlotID = rSource.SlotID; lInstance.WeaponSetID = rSource.WeaponSetID; lInstance.Form = rSource.Form; // Reset the sent flags. We do this so messages are flagged as 'completed' // by default. lInstance.IsSent = false; lInstance.IsHandled = false; // For this type, guarentee we have something // to hand back tot he caller return(lInstance); }
/// <summary> /// Returns an element back to the pool. /// </summary> /// <param name="rEdge"></param> public static void Release(InventoryMessage rInstance) { if (rInstance == null) { return; } // We should never release an instance unless we're // sure we're done with it. So clearing here is fine rInstance.Clear(); // Reset the sent flags. We do this so messages are flagged as 'completed' // and removed by default. rInstance.IsSent = true; rInstance.IsHandled = true; // Make it available to others. sPool.Release(rInstance); }