private void CascadeActivation(IActivationContext context) { IActivationDepth depth = context.Depth(); if (!depth.RequiresActivation()) { return; } if (depth.Mode().IsDeactivate()) { Container().StillToDeactivate(_transaction, context.TargetObject(), depth, false); } else { // FIXME: [TA] do we really need to check for isValueType here? Db4objects.Db4o.Internal.ClassMetadata classMetadata = context.ClassMetadata(); if (classMetadata.IsStruct()) { classMetadata.CascadeActivation(context); } else { Container().StillToActivate(context); } } }
public virtual void Activate(Db4objects.Db4o.Internal.Transaction ta, object obj, IActivationDepth depth) { ObjectContainerBase container = ta.Container(); ActivateInternal(container.ActivationContextFor(ta, obj, depth)); container.ActivatePending(ta); }
public virtual void TestDescendingFromNonTAAwareToTAAware() { IActivationDepth depth = NonTAAwareDepth(); IActivationDepth child = depth.Descend(ClassMetadataFor(typeof(TransparentActivationDepthTestCase.TAAware ))); Assert.IsFalse(child.RequiresActivation()); }
public virtual void Activate(Transaction ta, object obj, IActivationDepth depth) { var container = ta.Container(); ActivateInternal(container.ActivationContextFor(ta, obj, depth)); container.ActivatePending(ta); }
public virtual void TestSpecificActivationDepth() { IActivationDepth depth = Provider().ActivationDepth(3, ActivationMode.Activate); AssertDescendingDepth(3, depth, typeof(TransparentActivationDepthTestCase.TAAware )); AssertDescendingDepth(3, depth, typeof(TransparentActivationDepthTestCase.NonTAAware )); }
public virtual void TestDefaultActivationNonTAAware() { IActivationDepth depth = NonTAAwareDepth(); Assert.IsTrue(depth.RequiresActivation()); IActivationDepth child = depth.Descend(ClassMetadataFor(typeof(TransparentActivationDepthTestCase.NonTAAware ))); Assert.IsTrue(child.RequiresActivation()); }
public ActivationContext4(Db4objects.Db4o.Internal.Transaction transaction, object obj, IActivationDepth depth) { if (null == obj) { throw new ArgumentNullException(); } _transaction = transaction; _targetObject = obj; _depth = depth; }
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()); }
private void AssertDescendingDepth(int expectedDepth, IActivationDepth depth, Type clazz) { if (expectedDepth < 1) { Assert.IsFalse(depth.RequiresActivation()); return; } Assert.IsTrue(depth.RequiresActivation()); AssertDescendingDepth(expectedDepth - 1, depth.Descend(ClassMetadataFor(clazz)), clazz); }
/// <exception cref="Db4objects.Db4o.Ext.DatabaseClosedException"></exception> public override object PeekPersisted(Transaction trans, object obj, IActivationDepth depth, bool committed) { _bypassSlotCache = true; try { return(base.PeekPersisted(trans, obj, depth, committed)); } finally { _bypassSlotCache = false; } }
public virtual object ReadFullyActivatedObjectForKeys(ITypeHandler4 handler) { object obj = ReadObject(handler); if (obj == null) { return(obj); } IActivationDepth activationDepth = ActivationDepthProvider().ActivationDepth(int.MaxValue , ActivationMode.Activate); Container().Activate(Transaction(), obj, activationDepth); return(obj); }
public virtual void Deactivate(Db4objects.Db4o.Internal.Transaction trans, IActivationDepth depth) { if (!depth.RequiresActivation()) { return; } object obj = GetObject(); if (obj == null) { return; } ObjectContainerBase container = trans.Container(); LogActivation(container, "deactivate"); SetStateDeactivated(); _class.Deactivate(trans, this, depth); }
public virtual void Deactivate(Transaction trans, IActivationDepth depth) { if (!depth.RequiresActivation()) { return; } var obj = GetObject(); if (obj == null) { return; } var container = trans.Container(); LogActivation(container, "deactivate"); SetStateDeactivated(); _class.Deactivate(trans, this, depth); }
public object ReadObject() { int objectId = ReadInt(); if (objectId == 0) { _lastReferenceReadWasReallyNull = true; return(null); } _lastReferenceReadWasReallyNull = false; if (objectId == Const4.InvalidObjectId) { return(null); } ClassMetadata classMetadata = ClassMetadataForObjectId(objectId); if (null == classMetadata) { // TODO: throw here return(null); } IActivationDepth depth = ActivationDepth().Descend(classMetadata); if (PeekPersisted()) { return(Container().PeekPersisted(Transaction(), objectId, depth, false)); } object obj = Container().GetByID2(Transaction(), objectId); if (null == obj) { return(null); } // this is OK for boxed value types. They will not be added // to the list, since they will not be found in the ID tree. Container().StillToActivate(Container().ActivationContextFor(Transaction(), obj, depth)); return(obj); }
public virtual void TestDefaultActivationTAAware() { IActivationDepth depth = TAAwareDepth(); Assert.IsFalse(depth.RequiresActivation()); }
public virtual void ForceDeactivation(Transaction trans, IActivationDepth depth, object obj) { DeactivateFields(trans.Container().ActivationContextFor(trans, obj, depth)); }
public virtual void Deactivate(Transaction trans, IObjectInfo reference, IActivationDepth depth) { var obj = reference.GetObject(); if (ObjectCanDeactivate(trans, reference)) { ForceDeactivation(trans, depth, obj); ObjectOnDeactivate(trans, reference); } }
internal object Read(Db4objects.Db4o.Internal.Transaction trans, IActivationDepth instantiationDepth, int addToIDTree, bool checkIDTree) { return(Read(trans, null, null, instantiationDepth, addToIDTree, checkIDTree)); }
public virtual ActivationContext4 ActivationContextFor(Transaction ta, object obj , IActivationDepth depth) { return new ActivationContext4(ta, obj, depth); }
public _IFunction4_189(ObjectContainerBase _enclosing, object obj, IActivationDepth depth) { this._enclosing = _enclosing; this.obj = obj; this.depth = depth; }
public void Activate(Db4objects.Db4o.Internal.Transaction trans, object obj, IActivationDepth depth) { lock (_lock) { AsTopLevelCall(new _IFunction4_189(this, obj, depth), trans); } }
public virtual ObjectReference PeekReference(Transaction trans, int id, IActivationDepth depth, bool resetJustPeeked) { ObjectReference @ref = new ObjectReference(id); @ref.PeekPersisted(trans, depth); if (resetJustPeeked) { _justPeeked = null; } return @ref; }
public _IFunction4_1271(ObjectContainerBase _enclosing, object obj, bool committed , IActivationDepth depth) { this._enclosing = _enclosing; this.obj = obj; this.committed = committed; this.depth = depth; }
/// <exception cref="Db4objects.Db4o.Ext.DatabaseClosedException"></exception> public virtual object PeekPersisted(Transaction trans, object obj, IActivationDepth depth, bool committed) { // TODO: peekPersisted is not stack overflow safe, if depth is too high. lock (_lock) { CheckClosed(); return AsTopLevelCall(new _IFunction4_1271(this, obj, committed, depth), trans); } }
internal void PeekPersisted(Db4objects.Db4o.Internal.Transaction trans, IActivationDepth depth) { SetObject(Read(trans, depth, Const4.Transient, false)); }
public object PeekPersisted(Transaction trans, int id, IActivationDepth depth, bool resetJustPeeked) { if (resetJustPeeked) { _justPeeked = null; } else { TreeInt ti = new TreeInt(id); TreeIntObject tio = (TreeIntObject)Tree.Find(_justPeeked, ti); if (tio != null) { return tio._object; } } ObjectReference @ref = PeekReference(trans, id, depth, resetJustPeeked); return @ref.GetObject(); }
// overridden to do nothing in YapObjectCarrier internal List4 StillTo1(Transaction trans, List4 still, object obj, IActivationDepth depth) { if (obj == null || !depth.RequiresActivation()) { return still; } ObjectReference @ref = trans.ReferenceForObject(obj); if (@ref != null) { if (HandledInCurrentTopLevelCall(@ref)) { return still; } FlagAsHandled(@ref); return new List4(still, new ObjectContainerBase.PendingActivation(@ref, depth)); } IReflectClass clazz = ReflectorForObject(obj); if (clazz.IsArray()) { if (!clazz.GetComponentType().IsPrimitive()) { IEnumerator arr = ArrayHandler.Iterator(clazz, obj); while (arr.MoveNext()) { object current = arr.Current; if (current == null) { continue; } ClassMetadata classMetadata = ClassMetadataForObject(current); still = StillTo1(trans, still, current, depth.Descend(classMetadata)); } } return still; } else { if (obj is Entry) { still = StillTo1(trans, still, ((Entry)obj).key, depth); still = StillTo1(trans, still, ((Entry)obj).value, depth); } else { if (depth.Mode().IsDeactivate()) { // Special handling to deactivate .net structs ClassMetadata metadata = ClassMetadataForObject(obj); if (metadata != null && metadata.IsStruct()) { metadata.ForceDeactivation(trans, depth, obj); } } } } return still; }
public void StillToDeactivate(Transaction trans, object a_object, IActivationDepth a_depth, bool a_forceUnknownDeactivate) { _stillToDeactivate = StillTo1(trans, _stillToDeactivate, a_object, a_depth); }
public PendingActivation(ObjectReference ref_, IActivationDepth depth_) { this.@ref = ref_; this.depth = depth_; }
internal object Read(Db4objects.Db4o.Internal.Transaction trans, IActivationDepth instantiationDepth, int addToIDTree, bool checkIDTree) { return Read(trans, null, null, instantiationDepth, addToIDTree, checkIDTree); }
private void DeactivateInternal(Transaction trans, object obj, IActivationDepth depth ) { StillToDeactivate(trans, obj, depth, true); DeactivatePending(trans); }
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 virtual void ActivationDepth(IActivationDepth depth) { _activationDepth = depth; }
/// <exception cref="Db4objects.Db4o.Ext.DatabaseClosedException"></exception> public override object PeekPersisted(Transaction trans, object obj, IActivationDepth depth, bool committed) { _bypassSlotCache = true; try { return base.PeekPersisted(trans, obj, depth, committed); } finally { _bypassSlotCache = false; } }