public virtual IReplicationReference ProduceReference(object obj, object unused, string unused2) { if (obj == null) { return(null); } if (_referencesByObject != null) { Db4oReplicationReferenceImpl existingNode = _referencesByObject.Find(obj); if (existingNode != null) { return(existingNode); } } // TODO: Why refresh here? Try without and run all tests! Refresh(obj); IObjectInfo objectInfo = _container.GetObjectInfo(obj); if (objectInfo == null) { return(null); } Db4oUUID uuid = objectInfo.GetUUID(); if (uuid == null) { throw new ArgumentNullException(); } Db4oReplicationReferenceImpl newNode = new Db4oReplicationReferenceImpl(objectInfo , obj); AddReference(newNode); return(newNode); }
/// <exception cref="System.Exception"></exception> protected override void Store() { LinkedArrays linkedArrays = LinkedArrays.NewLinkedArrayRoot(TestedDepth); Store(linkedArrays); _linkedArraysUUID = Db().GetObjectInfo(linkedArrays).GetUUID(); }
public T GetByUUID <T>(Db4oUUID uuid) where T : class { var o = GetByUUID(uuid); Activate(o); return((T)o); }
/// <exception cref="System.Exception"></exception> public virtual void Conc(IExtObjectContainer oc) { var os = oc.Query(typeof(InvalidUUIDTestCase)); if (os.Count == 0) { // already deleted by other threads return; } Assert.AreEqual(1, os.Count); var iu = (InvalidUUIDTestCase)os.Next(); var myUuid = oc.GetObjectInfo(iu).GetUUID(); Assert.IsNotNull(myUuid); var mySignature = myUuid.GetSignaturePart(); var myLong = myUuid.GetLongPart(); var unknownLong = long.MaxValue - 100; byte[] unknownSignature = { 1, 2, 4, 99, 33, 22 }; var unknownLongPart = new Db4oUUID(unknownLong, mySignature); var unknownSignaturePart = new Db4oUUID(myLong, unknownSignature); var unknownBoth = new Db4oUUID(unknownLong, unknownSignature); Assert.IsNull(oc.GetByUUID(unknownLongPart)); Assert.IsNull(oc.GetByUUID(unknownSignaturePart)); Assert.IsNull(oc.GetByUUID(unknownBoth)); Assert.IsNull(oc.GetByUUID(unknownLongPart)); Thread.Sleep(500); oc.Delete(iu); oc.Commit(); Assert.IsNull(oc.GetByUUID(myUuid)); }
public override T GetByUUID <T>(Db4oUUID uuid) { var o = GetByUUID(uuid); Activate(o); return((T)o); }
/// <exception cref="System.Exception"></exception> protected override void Store() { var item = new Item(); Store(item); _uuid = Db().GetObjectInfo(item).GetUUID(); }
/// <exception cref="Db4objects.Db4o.Ext.DatabaseClosedException"></exception> /// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception> public virtual object GetByUUID(Db4oUUID uuid) { lock (Lock()) { CheckClosed(); return(_server.GetByUUID(_transaction, uuid)); } }
/// <exception cref="System.Exception"></exception> protected override void Store() { var value = CreateItem(); _clazz = value.GetType(); Store(value); id = Db().Ext().GetID(value); uuid = Db().Ext().GetObjectInfo(value).GetUUID(); }
public virtual void TestGetUUIDInCommittedCallbacks() { Db4oUUID itemUUID = GetItemUUID(); ServerEventRegistry().Committed += new System.EventHandler <Db4objects.Db4o.Events.CommitEventArgs> (new _IEventListener4_34(itemUUID).OnEvent); DeleteAll(typeof(GetUUIDTestCase.Item)); Db().Commit(); }
private Db4oUUID SingleItemUUID() { UUIDDefragmentTestCase.Item item = (UUIDDefragmentTestCase.Item)((UUIDDefragmentTestCase.Item )RetrieveOnlyInstance(typeof(UUIDDefragmentTestCase.Item))); IObjectInfo objectInfo = Db().GetObjectInfo(item); Db4oUUID uuid = objectInfo.GetUUID(); return(uuid); }
/// <exception cref="System.Exception"></exception> public virtual void TestGetByUUID() { Fixture().Config().GenerateUUIDs(ConfigScope.Globally); Fixture().Reopen(this); Db4oIOExceptionTestCase.Item item = new Db4oIOExceptionTestCase.Item(1); Store(item); Db4oUUID uuid = Db().GetObjectInfo(item).GetUUID(); Fixture().Reopen(this); Assert.Expect(typeof(Db4oIOException), new _ICodeBlock_122(this, uuid)); }
/// <exception cref="System.Exception"></exception> protected override void Db4oSetupAfterStore() { object customer = ((Customer)RetrieveOnlyInstance(typeof(Customer))); object country = ((Country)RetrieveOnlyInstance(typeof(Country))); customerID = Db().GetID(customer); countryID = Db().GetID(country); customerUUID = Db().GetObjectInfo(customer).GetUUID(); countryUUID = Db().GetObjectInfo(country).GetUUID(); Reopen(); }
/// <summary> /// Converts to string. /// </summary> /// <param name="UUID">The UUID.</param> /// <returns></returns> public static string ConvertToString(this Db4oUUID UUID) { if (UUID == null) { return(null); } return(String.Format("{0}|{1}", UUID.GetLongPart() , ByteArrayToString(UUID.GetSignaturePart()))); }
public virtual void TestTimeStamp() { IQuery q = NewItemQuery(); q.Descend("name").Constrain("one"); UUIDTestCase.Item item = (UUIDTestCase.Item)q.Execute().Next(); Db4oUUID uuid = Uuid(item); long longPart = uuid.GetLongPart(); long creationTime = TimeStampIdGenerator.IdToMilliseconds(longPart); Assert.IsGreaterOrEqual(storeStartTime, creationTime); Assert.IsSmallerOrEqual(storeEndTime, creationTime); }
/// <exception cref="System.Exception"></exception> public virtual void Test() { Db4oUUID uuidBeforeDefragment = SingleItemUUID(); byte[] signatureBeforeDefragment = uuidBeforeDefragment.GetSignaturePart(); long longPartBeforeDefragment = uuidBeforeDefragment.GetLongPart(); Defragment(); Db4oUUID uuidAfterDefragment = SingleItemUUID(); byte[] signatureAfterDefragment = uuidAfterDefragment.GetSignaturePart(); long longPartAfterDefragment = uuidAfterDefragment.GetLongPart(); ArrayAssert.AreEqual(signatureBeforeDefragment, signatureAfterDefragment); Assert.AreEqual(longPartBeforeDefragment, longPartAfterDefragment); }
/// <summary> /// Activates the specified UUID. /// </summary> /// <param name="UUID">The UUID.</param> /// <param name="container">The container.</param> /// <param name="activationDepth">The activation depth.</param> public static void Activate(this Db4oUUID UUID, IObjectContainer container, int activationDepth) { if (UUID == null) { return; } var item = container.Ext().GetByUUID(UUID); if (item == null) { return; } container.Activate(item, activationDepth); return; }
/// <summary> /// Gets the activated. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="UUID">The UUID.</param> /// <param name="container">The container.</param> /// <param name="activationDepth">The activation depth.</param> /// <returns></returns> public static T GetActivated <T>(this Db4oUUID UUID, IObjectContainer container, int activationDepth) { if (UUID == null) { return(default(T)); } var item = container.Ext().GetByUUID(UUID); if (item == null) { return(default(T)); } container.Activate(item, activationDepth); return((T)item); }
public string GetUUID() { try { IObjectInfo objInfo = objectContainer.Ext().GetObjectInfo(m_genObject); if (objInfo != null) { Db4oUUID uuid = objInfo.GetUUID(); return(uuid != null?uuid.GetLongPart().ToString() : "NA"); } return("NA"); } catch (Exception oEx) { LoggingHelper.HandleException(oEx); return("NA"); } }
protected virtual void AssertItemsCanBeRetrievedByUUID(Hashtable4 uuidCache) { IQuery q = NewItemQuery(); IObjectSet objectSet = q.Execute(); while (objectSet.HasNext()) { UUIDTestCase.Item item = (UUIDTestCase.Item)objectSet.Next(); Db4oUUID uuid = Uuid(item); Assert.IsNotNull(uuid); Assert.AreSame(item, Db().GetByUUID(uuid)); Db4oUUID cached = (Db4oUUID)uuidCache.Get(item.name); if (cached != null) { Assert.AreEqual(cached, uuid); } else { uuidCache.Put(item.name, uuid); } } }
/// <exception cref="Db4objects.Db4o.Ext.DatabaseClosedException"></exception> /// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception> public virtual object GetByUUID(Db4oUUID uuid) { throw new NotImplementedException(); }
public _IEventListener4_34(Db4oUUID itemUUID) { this.itemUUID = itemUUID; }
public DrsUUIDImpl(Db4oUUID db4oUUID) : this(db4oUUID.GetSignaturePart(), db4oUUID .GetLongPart()) { }
/// <exception cref="System.Exception"></exception> protected override void Store() { DeleteUUIDTestCase.Item item = new DeleteUUIDTestCase.Item(); Store(item); _uuid = Db().GetObjectInfo(item).GetUUID(); }
public _ICodeBlock_122(Db4oIOExceptionTestCase _enclosing, Db4oUUID uuid) { this._enclosing = _enclosing; this.uuid = uuid; }
public sealed override object GetByUUID(Db4oUUID uuid) { return(GetByUUID(null, uuid)); }