Ejemplo n.º 1
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();
		}
Ejemplo n.º 2
0
 private object WriteAndRead(object obj)
 {
     var imaginativeID = 500;
     var @ref = new ObjectReference(ClassMetadataForObject(obj), imaginativeID
         );
     @ref.SetObject(obj);
     var marshallingContext = new MarshallingContext(Trans(), @ref, Container
         ().UpdateDepthProvider().ForDepth(int.MaxValue), true);
     Handlers4.Write(@ref.ClassMetadata().TypeHandler(), marshallingContext, obj);
     var pointer = marshallingContext.AllocateSlot();
     var buffer = marshallingContext.ToWriteBuffer(pointer);
     buffer.Seek(0);
     //        String str = new String(buffer._buffer);
     //        System.out.println(str);
     var unmarshallingContext = new UnmarshallingContext(Trans(), @ref
         , Const4.AddToIdTree, false);
     unmarshallingContext.Buffer(buffer);
     unmarshallingContext.ActivationDepth(new LegacyActivationDepth(5));
     return unmarshallingContext.Read();
 }
Ejemplo n.º 3
0
		public virtual void AttemptUpdate(UnmarshallingContext context)
		{
			if (!Updating())
			{
				IncrementOffset(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);
			}
		}