Пример #1
0
            public override void WriteUpdate(Transaction transaction, IUpdateDepth updatedepth
                                             )
            {
                if (!_firstUpdate)
                {
                    base.WriteUpdate(transaction, updatedepth);
                    return;
                }
                _firstUpdate = false;
                var container = transaction.Container();

                SetStateClean();
                var context = new MarshallingContext(transaction, this, updatedepth
                                                     , false);

                Handlers4.Write(ClassMetadata().TypeHandler(), context, GetObject());
                var length = Container().BlockConverter().BlockAlignedBytes(context.MarshalledLength
                                                                                ());
                var slot    = context.AllocateNewSlot(length);
                var pointer = new Pointer4(GetID(), slot);
                var buffer  = context.ToWriteBuffer(pointer);

                container.WriteUpdate(transaction, pointer, ClassMetadata(), ArrayType.None,
                                      buffer);
                if (IsActive())
                {
                    SetStateClean();
                }
            }
Пример #2
0
            public override void WriteUpdate(Transaction transaction, IUpdateDepth updatedepth
                                             )
            {
                if (!this._firstUpdate)
                {
                    base.WriteUpdate(transaction, updatedepth);
                    return;
                }
                this._firstUpdate = false;
                ObjectContainerBase container = transaction.Container();

                this.SetStateClean();
                MarshallingContext context = new MarshallingContext(transaction, this, updatedepth
                                                                    , false);

                Handlers4.Write(this.ClassMetadata().TypeHandler(), context, this.GetObject());
                int length = this.Container().BlockConverter().BlockAlignedBytes(context.MarshalledLength
                                                                                     ());
                Slot            slot    = context.AllocateNewSlot(length);
                Pointer4        pointer = new Pointer4(this.GetID(), slot);
                ByteArrayBuffer buffer  = context.ToWriteBuffer(pointer);

                container.WriteUpdate(transaction, pointer, this.ClassMetadata(), ArrayType.None,
                                      buffer);
                if (this.IsActive())
                {
                    this.SetStateClean();
                }
            }
Пример #3
0
        public virtual void WriteUpdate(Db4objects.Db4o.Internal.Transaction transaction,
                                        IUpdateDepth updatedepth)
        {
            ContinueSet(transaction, updatedepth);
            // make sure, a concurrent new, possibly triggered by objectOnNew
            // is written to the file
            // preventing recursive
            if (!BeginProcessing())
            {
                return;
            }
            object obj = GetObject();

            if (!ObjectCanUpdate(transaction, obj) || !IsActive() || obj == null || !ClassMetadata
                    ().IsModified(obj))
            {
                EndProcessing();
                return;
            }
            MarshallingContext context = new MarshallingContext(transaction, this, updatedepth
                                                                , false);

            if (context.UpdateDepth().Negative())
            {
                EndProcessing();
                return;
            }
            ObjectContainerBase container = transaction.Container();

            LogEvent(container, "update", Const4.State);
            SetStateClean();
            context.PurgeFieldIndexEntriesOnUpdate(transaction, container._handlers.ArrayType
                                                       (obj));
            Handlers4.Write(_class.TypeHandler(), context, obj);
            if (context.UpdateDepth().CanSkip(this))
            {
                EndProcessing();
                return;
            }
            Pointer4        pointer = context.AllocateSlot();
            ByteArrayBuffer buffer  = context.ToWriteBuffer(pointer);

            container.WriteUpdate(transaction, pointer, _class, container._handlers.ArrayType
                                      (obj), buffer);
            if (IsActive())
            {
                SetStateClean();
            }
            EndProcessing();
            container.Callbacks().ObjectOnUpdate(transaction, this);
            ClassMetadata().DispatchEvent(transaction, obj, EventDispatchers.Update);
        }
Пример #4
0
        /// <summary>return false if class not completely initialized, otherwise true</summary>
        internal virtual bool ContinueSet(Db4objects.Db4o.Internal.Transaction trans, IUpdateDepth
                                          updateDepth)
        {
            if (!BitIsTrue(Const4.Continue))
            {
                return(true);
            }
            if (!_class.StateOK())
            {
                return(false);
            }
            if (!_class.AspectsAreInitialized())
            {
                return(false);
            }
            if (DTrace.enabled)
            {
                DTrace.Continueset.Log(GetID());
            }
            BitFalse(Const4.Continue);
            MarshallingContext context = new MarshallingContext(trans, this, updateDepth, true
                                                                );

            Handlers4.Write(ClassMetadata().TypeHandler(), context, GetObject());
            Pointer4            pointer   = context.AllocateSlot();
            ByteArrayBuffer     buffer    = context.ToWriteBuffer(pointer);
            ObjectContainerBase container = trans.Container();

            container.WriteNew(trans, pointer, _class, buffer);
            object obj = _object;

            ObjectOnNew(trans, obj);
            if (_class.HasIdentity())
            {
                _object = container.NewWeakReference(this, obj);
            }
            SetStateClean();
            EndProcessing();
            return(true);
        }
Пример #5
0
        private object WriteAndRead(object obj)
        {
            int             imaginativeID = 500;
            ObjectReference @ref          = new ObjectReference(ClassMetadataForObject(obj), imaginativeID
                                                                );

            @ref.SetObject(obj);
            MarshallingContext marshallingContext = new MarshallingContext(Trans(), @ref, Container
                                                                               ().UpdateDepthProvider().ForDepth(int.MaxValue), true);

            Handlers4.Write(@ref.ClassMetadata().TypeHandler(), marshallingContext, obj);
            Pointer4        pointer = marshallingContext.AllocateSlot();
            ByteArrayBuffer buffer  = marshallingContext.ToWriteBuffer(pointer);

            buffer.Seek(0);
            //        String str = new String(buffer._buffer);
            //        System.out.println(str);
            UnmarshallingContext unmarshallingContext = new UnmarshallingContext(Trans(), @ref
                                                                                 , Const4.AddToIdTree, false);

            unmarshallingContext.Buffer(buffer);
            unmarshallingContext.ActivationDepth(new LegacyActivationDepth(5));
            return(unmarshallingContext.Read());
        }