/// <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()))); }
/// <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))); }
/// <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); }
/// <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); }
/// <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())))); }