示例#1
0
文件: Topic.cs 项目: yongwuhou/NCache
        private void GetMessagePayLoad(MessageItem messageItem)
        {
            if (messageItem != null && messageItem.Payload != null)
            {
                MessageItemType type = GetMessageItemType(messageItem);

                switch (type)
                {
                case MessageItemType.MessageItems:
                    GetMessageItemPayLoad(messageItem);
                    break;

                case MessageItemType.MessageEventItem:
                    messageItem.Payload = GetMessageEventItemPayLoad((MessageEventItem)messageItem.Payload);
                    break;

                case MessageItemType.MessageEventItems:
                    MessageEventItem[] items = (MessageEventItem[])messageItem.Payload;

                    if (items != null)
                    {
                        MessageEventItem[] payLoads = new MessageEventItem[items.Length];

                        for (int count = 0; count < items.Length; count++)
                        {
                            payLoads[count] = GetMessageEventItemPayLoad(items[count]);
                        }
                        messageItem.Payload = payLoads;
                    }
                    break;
                }
            }
        }
示例#2
0
文件: Topic.cs 项目: yongwuhou/NCache
 private MessageEventItem GetMessageEventItemPayLoad(MessageEventItem eventItem)
 {
     if (eventItem != null && eventItem.Item != null)
     {
         eventItem.Item.SetValue(_cacheImpl.SafeDeserialize <object>(eventItem.Item.GetValue <object>(), _cacheImpl.Name, eventItem.Item.Flagmap, _cacheImpl, UserObjectType.CacheItem));
     }
     return(eventItem);
 }
示例#3
0
        internal void OnGeneralEventMessageReceived(MessageEventItem eventMessage)
        {
            string key = eventMessage.Key;

            switch (eventMessage.EventType)
            {
            case Alachisoft.NCache.Persistence.EventType.ITEM_ADDED_EVENT:
                RaiseGeneralCacheNotification(key, EventType.ItemAdded, eventMessage.Item, null, CacheItemRemovedReason.Underused, false);
                break;

            case Alachisoft.NCache.Persistence.EventType.ITEM_UPDATED_EVENT:
                RaiseGeneralCacheNotification(key, EventType.ItemUpdated, eventMessage.Item, eventMessage.OldItem, CacheItemRemovedReason.Underused, false);
                break;

            case Alachisoft.NCache.Persistence.EventType.ITEM_REMOVED_EVENT:
                RaiseGeneralCacheNotification(key, EventType.ItemRemoved, eventMessage.Item, null, eventMessage.Reason, false);
                break;
            }
        }
示例#4
0
        internal void OnSelectiveEventsMessageRecieved(MessageEventItem eventMessage)
        {
            string       key    = eventMessage.Key;
            CallbackInfo cbInfo = new CallbackInfo(null, eventMessage.Callback, eventMessage.DataFilter);
            EventHandle  handle = null;

            if (cbInfo != null)
            {
                short handler = (short)cbInfo.Callback;
                handle = new EventHandle(handler);
            }

            switch (eventMessage.EventType)
            {
            case Alachisoft.NCache.Persistence.EventType.ITEM_UPDATED_CALLBACK:
                RaiseSelectiveCacheNotification(key, EventType.ItemUpdated, eventMessage.Item, eventMessage.OldItem, CacheItemRemovedReason.Underused, false, handle, cbInfo.DataFilter);
                break;

            case Alachisoft.NCache.Persistence.EventType.ITEM_REMOVED_CALLBACK:
                RaiseSelectiveCacheNotification(key, EventType.ItemRemoved, eventMessage.Item, null, eventMessage.Reason, false, handle, cbInfo.DataFilter);
                break;
            }
        }