Ejemplo n.º 1
0
        /// <summary>
        ///     Handles the Removed event of the DistributedMemoryManagerCache control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="KeyCacheEventArgs{TKey}" /> instance containing the event data.</param>
        protected override void DistributedMemoryManagerCache_Removed(object sender, KeyCacheEventArgs <long> e)
        {
            using (var entityTypeContext = new EntityTypeContext( ))
            {
                HashSet <long> types = entityTypeContext.Get(e.Key);

                var message = new EntityFieldCacheMessage( );
                message.RemoveKeys.Add(SerializableEntityId.Create(e.Key, types));

                MessageChannel.Publish(message, PublishOptions.None, false, MergeMessages);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Removes the specified key.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">key</exception>
        public bool Remove(EntityRelationshipCacheKey key)
        {
            using (var entityTypeContext = new EntityTypeContext( ))
            {
                IEntity entity = EntityCache.Instance.Get(key.EntityId);

                if (entity != null)
                {
                    entityTypeContext.Merge(key.EntityId, entity.TypeIds);
                }

                bool result = ProviderRemove(key);

                HashSet <long> typeIds = entityTypeContext.Get(key.EntityId);

                var message = new EntityRelationshipCacheMessage( );
                message.RemoveKeys.Add(new SerializableEntityRelationshipCacheKey(SerializableEntityId.Create(key.EntityId, typeIds), key.Direction));

                MessageChannel.Publish(message, PublishOptions.FireAndForget, false, MergeMessages);

                return(result);
            }
        }
 /// <summary>
 ///     Initializes a new instance of the <see cref="SerializableEntityRelationshipCacheTypeKey" /> class.
 /// </summary>
 /// <param name="entityId">The primary key.</param>
 /// <param name="direction">The direction.</param>
 /// <param name="typeId">The type identifier.</param>
 public SerializableEntityRelationshipCacheTypeKey(SerializableEntityId entityId, Direction direction, long typeId)
 {
     EntityId  = entityId;
     Direction = direction;
     TypeId    = typeId;
 }
 /// <summary>
 ///     Initializes a new instance of the <see cref="SerializableEntityRelationshipCacheKey" /> class.
 /// </summary>
 /// <param name="entityId">The entity identifier.</param>
 /// <param name="direction">The direction.</param>
 public SerializableEntityRelationshipCacheKey(SerializableEntityId entityId, Direction direction)
     : this()
 {
     EntityId  = entityId;
     Direction = direction;
 }