/// <summary> /// Gets the deflatted value of the of the object in the value. It does not /// deflatten the actual object. /// </summary> internal object DeflattedValue(string cacheContext) { object obj = Value; //There is possibility that two threads simultaneously do deserialization; therefore //we must deserialize the entry in synchronized fashion. lock (this) { if (IsFlattened) { // Setting the Value resets the Flat flag! UserBinaryObject ub = null; CallbackEntry cbEntry = obj as CallbackEntry; if (cbEntry != null) { ub = cbEntry.Value as UserBinaryObject; } else { ub = obj as UserBinaryObject; } byte[] data = ub.GetFullObject(); _size = data.Length; obj = CompactBinaryFormatter.FromByteBuffer(data, cacheContext); if (cbEntry != null) { cbEntry.Value = obj; obj = cbEntry; } } } return(obj); }
public object GetCacheData(object data, BitSet flag) { byte[] serializedObject = null; try { UserBinaryObject userBinaryObject = null; if (data is UserBinaryObject) { userBinaryObject = (UserBinaryObject)data; } else { userBinaryObject = UserBinaryObject.CreateUserBinaryObject((ICollection)data); } if (userBinaryObject != null) { serializedObject = userBinaryObject.GetFullObject() as byte[]; return(SerializationUtil.SafeDeserialize(serializedObject, _context.SerializationContext, flag)); } } catch (Exception ex) { if (_context.NCacheLog != null && _context.NCacheLog.IsErrorEnabled) { _context.NCacheLog.Error("ObjectDataFormatService.GetCacheData()", ex.Message); } } return(data); }