示例#1
0
        /// <summary>
        /// Does this contain the specified entity
        /// </summary>
        /// <param name="entity">the entity in question</param>
        /// <returns>yes it contains it or no it does not</returns>
        public bool Contains(T entity, string namedContainer)
        {
            if (string.IsNullOrWhiteSpace(namedContainer))
            {
                return(Contains(entity));
            }

            LiveCacheKey key = new LiveCacheKey(entity);

            return(Birthmarks[namedContainer].Any(mark => mark.KeyHash().Equals(key.KeyHash())));
        }
示例#2
0
        /// <summary>
        /// Add an entity to this
        /// </summary>
        /// <param name="entity">the entity to add</param>
        /// <returns>success status</returns>
        public bool Add(T entity)
        {
            LiveCacheKey newKey = new LiveCacheKey(entity);

            if (Birthmarks[genericCollectionLabel].Any(mark => mark.KeyHash().Equals(newKey.KeyHash())))
            {
                return(false);
            }

            return(Birthmarks[genericCollectionLabel].Add(new LiveCacheKey(entity)));
        }
示例#3
0
        /// <summary>
        /// Remove an entity from this
        /// </summary>
        /// <param name="birthMark">the entity's birthmark to remove</param>
        /// <returns>success status</returns>
        public bool Remove(ICacheKey cacheKey, string namedContainer)
        {
            if (string.IsNullOrWhiteSpace(namedContainer))
            {
                return(Remove(cacheKey));
            }

            LiveCacheKey key = (LiveCacheKey)cacheKey;

            if (!Birthmarks[namedContainer].Any(mark => mark.KeyHash().Equals(key.KeyHash())))
            {
                return(false);
            }

            return(Birthmarks[namedContainer].RemoveWhere(keys => keys == key) > 0);
        }
示例#4
0
        /// <summary>
        /// Remove an entity from this
        /// </summary>
        /// <param name="birthMark">the entity's birthmark to remove</param>
        /// <returns>success status</returns>
        public bool Remove(ICacheKey cacheKey)
        {
            LiveCacheKey newKey = (LiveCacheKey)cacheKey;

            if (!Birthmarks[genericCollectionLabel].Any(mark => mark.KeyHash().Equals(newKey.KeyHash())))
            {
                return(false);
            }

            return(Birthmarks[genericCollectionLabel].RemoveWhere(key => key.BirthMark == newKey.BirthMark) > 0);
        }
示例#5
0
        /// <summary>
        /// Does this contain the specified entity
        /// </summary>
        /// <param name="entity">the entity in question</param>
        /// <returns>yes it contains it or no it does not</returns>
        public bool Contains(T entity)
        {
            LiveCacheKey newKey = new LiveCacheKey(entity);

            return(Birthmarks.Values.Any(hs => hs.Any(mark => mark.KeyHash().Equals(newKey.KeyHash()))));
        }