예제 #1
0
        public object Read(Db4objects.Db4o.Internal.Transaction trans, ByteArrayBuffer buffer
                           , object obj, IActivationDepth instantiationDepth, int addToIDTree, bool checkIDTree
                           )
        {
            UnmarshallingContext context = new UnmarshallingContext(trans, buffer, this, addToIDTree
                                                                    , checkIDTree);

            context.PersistentObject(obj);
            context.ActivationDepth(instantiationDepth);
            return(context.Read());
        }
        public override object Instantiate(UnmarshallingContext context)
        {
            object obj = context.PersistentObject();

            if (obj == null)
            {
                obj = context.Read(TypeHandler());
                context.SetObjectWeak(obj);
            }
            context.SetStateClean();
            return(obj);
        }
예제 #3
0
        public override void Activate(UnmarshallingContext context)
        {
            object obj = Read(context);

            // Activation of members is necessary on purpose here.
            // Classes like Hashtable need fully activated members
            // to be able to calculate hashCode()
            if (obj != null)
            {
                context.Container().Activate(context.Transaction(), obj, context.ActivationDepth(
                                                 ));
            }
            SetOn(context.Transaction(), context.PersistentObject(), obj);
        }
예제 #4
0
        public override void Activate(UnmarshallingContext context)
        {
            if (!CheckAlive(context, context))
            {
                return;
            }
            if (!ShouldStoreField())
            {
                IncrementOffset(context, context);
                return;
            }
            object toSet = Read(context);

            InformAboutTransaction(toSet, context.Transaction());
            Set(context.PersistentObject(), toSet);
        }
예제 #5
0
        public static int SlotHandlerVersion(IExtObjectContainer objectContainer, object
                                             obj)
        {
            int                  id         = (int)objectContainer.GetID(obj);
            IObjectInfo          objectInfo = objectContainer.GetObjectInfo(obj);
            ObjectContainerBase  container  = (ObjectContainerBase)objectContainer;
            Transaction          trans      = container.Transaction;
            ByteArrayBuffer      buffer     = container.ReadBufferById(trans, id);
            UnmarshallingContext context    = new UnmarshallingContext(trans, (ObjectReference)objectInfo
                                                                       , Const4.Transient, false);

            context.Buffer(buffer);
            context.PersistentObject(obj);
            context.ActivationDepth(new LegacyActivationDepth(0));
            context.Read();
            return(context.HandlerVersion());
        }
예제 #6
0
        public virtual void Activate(IReferenceActivationContext context)
        {
            UnmarshallingContext unmarshallingContext = (UnmarshallingContext)context;
            IDictionary          map = (IDictionary)unmarshallingContext.PersistentObject();

            map.Clear();
            KeyValueHandlerPair handlers = ReadKeyValueTypeHandlers(context, context);
            int elementCount             = context.ReadInt();

            for (int i = 0; i < elementCount; i++)
            {
                object key = unmarshallingContext.ReadFullyActivatedObjectForKeys(handlers._keyHandler
                                                                                  );
                if (key == null && !unmarshallingContext.LastReferenceReadWasReallyNull())
                {
                    continue;
                }
                object value = context.ReadObject(handlers._valueHandler);
                map[key] = value;
            }
        }
예제 #7
0
 protected override void ProcessAspect(ClassAspect aspect, int currentSlot, bool isNull
                                       )
 {
     if (aspect is FieldMetadata)
     {
         var field = (FieldMetadata)aspect;
         if (field.Updating())
         {
             schemaUpdateDetected.value = true;
         }
         if (isNull)
         {
             if (field.GetStoredType() == null || !field.GetStoredType().IsPrimitive())
             {
                 field.Set(context.PersistentObject(), null);
             }
             return;
         }
     }
     aspect.Activate(context);
 }
예제 #8
0
        public virtual void AttemptUpdate(UnmarshallingContext context)
        {
            if (!Updating())
            {
                IncrementOffset(context, context);
                return;
            }
            int savedOffset = context.Offset();

            try
            {
                object toSet = context.Read(GetHandler());
                if (toSet != null)
                {
                    Set(context.PersistentObject(), toSet);
                }
            }
            catch (Exception)
            {
                // FIXME: COR-547 Diagnostics here please.
                context.Buffer().Seek(savedOffset);
                IncrementOffset(context, context);
            }
        }