Ejemplo n.º 1
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);
		}
Ejemplo n.º 2
0
		public override void Marshall(MarshallingContext context, object obj)
		{
			// alive needs to be checked by all callers: Done
			IUpdateDepth updateDepth = context.UpdateDepth();
			if (obj != null && CascadeOnUpdate(context.ClassConfiguration()))
			{
				context.UpdateDepth(AdjustUpdateDepthForCascade(obj, updateDepth));
			}
			context.WriteObjectWithCurrentState(GetHandler(), obj);
			context.UpdateDepth(updateDepth);
			if (HasIndex())
			{
				context.AddIndexEntry(this, obj);
			}
		}