System.LocalDataStoreMgr.ValidateSlot C# (CSharp) Method

ValidateSlot() public method

public ValidateSlot ( LocalDataStoreSlot slot ) : void
slot LocalDataStoreSlot
return void
	    public void ValidateSlot(LocalDataStoreSlot slot)
	    {
            // Make sure the slot was allocated for this store.
	        if (slot==null || slot.Manager != this)
                throw new ArgumentException(Environment.GetResourceString("Argument_ALSInvalidSlot"));
        }

Usage Example

        /*=========================================================================
        ** Retrieves the value from the specified slot.
        ** =========================================================================*/
        public Object GetData(LocalDataStoreSlot slot)
        {
            Object o = null;

            // Validate the slot.
            m_Manager.ValidateSlot(slot);

            // Cache the slot index to avoid synchronization issues.
            int slotIdx = slot.Slot;

            if (slotIdx >= 0)
            {
                // Delay expansion of m_DataTable if we can
                if (slotIdx >= m_DataTable.Length)
                {
                    return(null);
                }

                // Retrieve the data from the given slot.
                o = m_DataTable[slotIdx];
            }

            // Check if the slot has become invalid.
            if (!slot.IsValid())
            {
                throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SlotHasBeenFreed"));
            }
            return(o);
        }
All Usage Examples Of System.LocalDataStoreMgr::ValidateSlot