public virtual object ReadPrefetch(Db4objects.Db4o.Internal.Transaction trans, ByteArrayBuffer buffer, int addToIDTree) { UnmarshallingContext context = new UnmarshallingContext(trans, buffer, this, addToIDTree , false); context.ActivationDepth(new FixedActivationDepth(1, ActivationMode.Prefetch)); return(context.Read()); }
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 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); }
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()); }
public object Get(Transaction trans, object onObject) { if (_containingClass == null) { return(null); } ObjectContainerBase container = Container(); if (container == null) { return(null); } lock (container.Lock()) { // FIXME: The following is not really transactional. // This will work OK for normal C/S and for // single local mode but the transaction will // be wrong for MTOC. if (trans == null) { trans = container.Transaction; } container.CheckClosed(); ObjectReference @ref = trans.ReferenceForObject(onObject); if (@ref == null) { return(null); } int id = @ref.GetID(); if (id <= 0) { return(null); } UnmarshallingContext context = new UnmarshallingContext(trans, @ref, Const4.AddToIdTree , false); context.ActivationDepth(new LegacyActivationDepth(1)); return(context.ReadFieldValue(this)); } }
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()); }