Example #1
0
        /// <summary>
        /// Locates purge object matching the specified object and id.
        /// </summary>
        /// <param name="purgeObject">Type of the object.</param>
        /// <param name="id">Id of the object.</param>
        public StackHashPurgeOptions FindPurgeOptions(StackHashPurgeObject purgeObject, int id)
        {
            Monitor.Enter(this);

            try
            {
                for (int i = 0; i < this.Count; i++)
                {
                    if ((this[i].PurgeObject == purgeObject) && (this[i].Id == id))
                    {
                        return(this[i]);
                    }
                }

                return(null);
            }
            finally
            {
                Monitor.Exit(this);
            }
        }
Example #2
0
        /// <summary>
        /// Removes the specified purge options.
        /// Only the object and id are matched.
        /// Does nothing if the purge option does not exist.
        /// </summary>
        /// <param name="purgeObject">Object to remove.</param>
        /// <param name="id">Id of object.</param>
        public bool RemovePurgeOption(StackHashPurgeObject purgeObject, int id)
        {
            Monitor.Enter(this);

            try
            {
                StackHashPurgeOptions foundPurgeOptions = this.FindPurgeOptions(purgeObject, id);
                if (foundPurgeOptions != null)
                {
                    this.Remove(foundPurgeOptions);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            finally
            {
                Monitor.Exit(this);
            }
        }