コード例 #1
0
ファイル: EventHelper.cs プロジェクト: javithalion/NCache
        internal static EventCacheItem ConvertToEventItem(EventCacheEntry entry, EventDataFilter? datafilter)
        {
            if (datafilter == EventDataFilter.None || entry == null)
                return null;

            EventCacheItem cacheItem = new EventCacheItem();

            cacheItem.priority = (int)entry.Priority;

            UserBinaryObject userBinary = entry.Value as UserBinaryObject;
            if (userBinary == null)
            {
                if (entry.Value is CallbackEntry)
                    userBinary = ((CallbackEntry)entry.Value).Value as UserBinaryObject;
            }

            if (userBinary != null)
                cacheItem.value.AddRange(userBinary.DataList);

            //Can be optimized
            if (datafilter != null)
            {
                if (datafilter == EventDataFilter.None)
                    return null;
                else if (datafilter == EventDataFilter.Metadata)
                    cacheItem.value.Clear();
            }

            return cacheItem;
        }
コード例 #2
0
ファイル: EventCacheEntry.cs プロジェクト: yongwuhou/NCache
        public static EventCacheEntry ReadItemInfo(CompactReader reader)
        {
            bool flag = reader.ReadBoolean();

            if (flag)
            {
                EventCacheEntry item = new EventCacheEntry();
                item.Deserialize(reader);
                return(item);
            }
            return(null);
        }
コード例 #3
0
ファイル: EventCacheEntry.cs プロジェクト: yongwuhou/NCache
 internal static void WriteItemInfo(CompactWriter writer, EventCacheEntry item)
 {
     if (item == null)
     {
         writer.Write(false);
         return;
     }
     else
     {
         writer.Write(true);
         item.Serialize(writer);
     }
 }
コード例 #4
0
ファイル: CacheHelper.cs プロジェクト: javithalion/NCache
        public static EventCacheEntry CreateCacheEventEntry(EventDataFilter? filter, CacheEntry cacheEntry)
        {
            if (filter != EventDataFilter.None && cacheEntry != null)
            {
                cacheEntry = (CacheEntry)cacheEntry.Clone();
                EventCacheEntry entry = new EventCacheEntry(cacheEntry);
                entry.Flags = cacheEntry.Flag;

                if (filter == EventDataFilter.DataWithMetadata)
                {
                    if (cacheEntry.Value is CallbackEntry)
                    {
                        entry.Value = ((CallbackEntry)cacheEntry.Value).Value;
                    }
                    else
                        entry.Value = cacheEntry.Value;

                }
                return entry;
            }
            return null;
        }
コード例 #5
0
ファイル: EventUtil.cs プロジェクト: javithalion/NCache
        /// <summary>
        /// For Inproc only
        /// </summary>
        /// <param name="entry"></param>
        /// <returns></returns>
        internal static EventCacheItem ConvertToItem(EventCacheEntry entry)
        {
            Byte[] objectValue = null;
            if (entry != null)
            {
                EventCacheItem item = new EventCacheItem();
                item.CacheItemPriority = (CacheItemPriority)entry.Priority;
                if (entry.Value != null)
                {
                    UserBinaryObject ubObject = entry.Value as UserBinaryObject;
                    if (ubObject != null)
                    {
                        objectValue = ubObject.GetFullObject();
                        item.Value = objectValue;
                    }
                    else
                        item.Value = entry.Value;
                }

                return item;
            }

            return null;
        }