public virtual void TestGetByUUID() { EmbeddedClientObjectContainerTestCase.Item storedItem = StoreItemToClient1AndCommit (); IObjectInfo objectInfo = _client1.GetObjectInfo(storedItem); object retrievedItem = _client1.GetByUUID(objectInfo.GetUUID()); Assert.AreSame(storedItem, retrievedItem); retrievedItem = _client2.GetByUUID(objectInfo.GetUUID()); Assert.AreNotSame(storedItem, retrievedItem); }
private void AssertGeneration(IObjectInfo objectInfo, bool expectGeneration) { if (expectGeneration) { Assert.IsNotNull(objectInfo.GetUUID()); } else { Assert.IsNull(objectInfo.GetUUID()); Assert.AreEqual(0L, objectInfo.GetCommitTimestamp()); } }
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); }
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); }
private void AssertInfosAreConsistent(long[] ids, IObjectInfo[] infos) { for (int i = 0; i < infos.Length; i++) { IObjectInfo info = Db().GetObjectInfo(Db().GetByID(ids[i])); Assert.AreEqual(info.GetInternalID(), infos[i].GetInternalID()); Assert.AreEqual(info.GetUUID().GetLongPart(), infos[i].GetUUID().GetLongPart()); Assert.AreSame(info.GetObject(), infos[i].GetObject()); } }
public void OnEvent(object sender, Db4objects.Db4o.Events.CommitEventArgs args) { CommitEventArgs commitEventArgs = (CommitEventArgs)args; IEnumerator deletedObjectInfoCollection = commitEventArgs.Deleted.GetEnumerator(); while (deletedObjectInfoCollection.MoveNext()) { IObjectInfo objectInfo = (IObjectInfo)deletedObjectInfoCollection.Current; Assert.IsNotNull(objectInfo.GetUUID()); } }
public virtual void Test() { IExtObjectContainer oc = this.Db(); ObjectVersionTest.Item @object = new ObjectVersionTest.Item("c1"); oc.Store(@object); IObjectInfo objectInfo1 = oc.GetObjectInfo(@object); long oldVer = objectInfo1.GetCommitTimestamp(); //Update @object.SetName("c3"); oc.Store(@object); IObjectInfo objectInfo2 = oc.GetObjectInfo(@object); long newVer = objectInfo2.GetCommitTimestamp(); Assert.IsNotNull(objectInfo1.GetUUID()); Assert.IsNotNull(objectInfo2.GetUUID()); Assert.IsTrue(oldVer > 0); Assert.IsTrue(newVer > 0); Assert.AreEqual(objectInfo1.GetUUID(), objectInfo2.GetUUID()); Assert.IsTrue(newVer > oldVer); }
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"); } }
private static void MigrationOnTheFly() { DeleteDatabases(); IObjectContainer desktopDatabaseWithoutUUID = Db4oEmbedded.OpenFile(DesktopDatabaseName); desktopDatabaseWithoutUUID.Store(new Car(new Pilot("Max"), "Max's Car")); desktopDatabaseWithoutUUID.Store(new Car(new Pilot("Joe"), "Joe's Car")); desktopDatabaseWithoutUUID.Commit(); desktopDatabaseWithoutUUID.Close(); IObjectContainer desktopDatabase = OpenDatabase(DesktopDatabaseName); IObjectContainer mobileDatabase = OpenDatabase(MobileDatabaseName); IReplicationProvider desktopRelicationPartner = new Db4oEmbeddedReplicationProvider(desktopDatabase); IReplicationProvider mobileRelicationPartner = new Db4oEmbeddedReplicationProvider(mobileDatabase); // #example: Migrate on the fly IReplicationSession replicationSession = Replication.Begin(desktopRelicationPartner, mobileRelicationPartner); IList <Car> initialReplication = desktopDatabase.Query <Car>(); foreach (Car changedObjectOnDesktop in initialReplication) { IObjectInfo infoAboutObject = desktopDatabase.Ext().GetObjectInfo(changedObjectOnDesktop); if (null == infoAboutObject.GetUUID()) { desktopDatabase.Ext().Store(changedObjectOnDesktop, 2); } replicationSession.Replicate(changedObjectOnDesktop); } replicationSession.Commit(); // #end example PrintCars(mobileDatabase); CloseDBs(desktopDatabase, mobileDatabase); }