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 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);
		}
Beispiel #3
0
 private object Activate(UnmarshallingContext context)
 {
     var obj = context.PersistentObject();
     var objectReference = context.ObjectReference();
     if (!ObjectCanActivate(context.Transaction(), obj))
     {
         objectReference.SetStateDeactivated();
         return obj;
     }
     objectReference.SetStateClean();
     if (context.ActivationDepth().RequiresActivation())
     {
         InstantiateFields(context);
     }
     ObjectOnActivate(context.Transaction(), objectReference);
     return obj;
 }
Beispiel #4
0
 private object InstantiateObject(UnmarshallingContext context)
 {
     var obj = _constructor.Apply(context);
     context.PersistentObject(obj);
     return obj;
 }
Beispiel #5
0
 public virtual object Instantiate(UnmarshallingContext context)
 {
     // overridden in PrimitiveTypeMetadata
     // never called for primitive YapAny
     // FIXME: [TA] no longer necessary?
     //        context.adjustInstantiationDepth();
     var obj = context.PersistentObject();
     var instantiating = (obj == null);
     if (instantiating)
     {
         obj = InstantiateObject(context);
         if (obj == null)
         {
             return null;
         }
         ShareTransaction(obj, context.Transaction());
         ShareObjectReference(obj, context.ObjectReference());
         OnInstantiate(context, obj);
         if (context.ActivationDepth().Mode().IsPrefetch())
         {
             context.ObjectReference().SetStateDeactivated();
             return obj;
         }
         if (!context.ActivationDepth().RequiresActivation())
         {
             context.ObjectReference().SetStateDeactivated();
             return obj;
         }
         return Activate(context);
     }
     if (ActivatingActiveObject(context.ActivationDepth().Mode(), context.ObjectReference
         ()))
     {
         var child = context.ActivationDepth().Descend(this);
         if (child.RequiresActivation())
         {
             CascadeActivation(new ActivationContext4(context.Transaction(), obj, child));
         }
         return obj;
     }
     return Activate(context);
 }
Beispiel #6
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();
		}
Beispiel #7
0
 public override object Instantiate(UnmarshallingContext context)
 {
     var obj = context.PersistentObject();
     if (obj == null)
     {
         obj = context.Read(TypeHandler());
         context.SetObjectWeak(obj);
     }
     context.SetStateClean();
     return obj;
 }
		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);
			}
		}
		public override void Activate(UnmarshallingContext context)
		{
			if (!CheckAlive(context))
			{
				return;
			}
			if (!ShouldStoreField())
			{
				IncrementOffset(context);
				return;
			}
			object toSet = Read(context);
			InformAboutTransaction(toSet, context.Transaction());
			Set(context.PersistentObject(), toSet);
		}