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);
        }
Пример #2
0
        /// <exception cref="System.Exception"></exception>
        protected override void Store()
        {
            LinkedArrays linkedArrays = LinkedArrays.NewLinkedArrayRoot(TestedDepth);

            Store(linkedArrays);
            _linkedArraysUUID = Db().GetObjectInfo(linkedArrays).GetUUID();
        }
Пример #3
0
        public T GetByUUID <T>(Db4oUUID uuid) where T : class
        {
            var o = GetByUUID(uuid);

            Activate(o);
            return((T)o);
        }
Пример #4
0
        /// <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));
        }
Пример #5
0
        public override T GetByUUID <T>(Db4oUUID uuid)
        {
            var o = GetByUUID(uuid);

            Activate(o);
            return((T)o);
        }
Пример #6
0
        /// <exception cref="System.Exception"></exception>
        protected override void Store()
        {
            var item = new Item();

            Store(item);
            _uuid = Db().GetObjectInfo(item).GetUUID();
        }
Пример #7
0
 /// <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));
     }
 }
Пример #8
0
        /// <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();
        }
Пример #9
0
        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);
        }
Пример #11
0
        /// <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));
        }
Пример #12
0
        /// <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();
        }
Пример #13
0
        /// <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())));
        }
Пример #14
0
        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);
        }
Пример #16
0
        /// <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;
        }
Пример #17
0
        /// <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);
        }
Пример #18
0
        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");
            }
        }
Пример #19
0
        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);
                }
            }
        }
Пример #20
0
 /// <exception cref="Db4objects.Db4o.Ext.DatabaseClosedException"></exception>
 /// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
 public virtual object GetByUUID(Db4oUUID uuid)
 {
     throw new NotImplementedException();
 }
Пример #21
0
 public _IEventListener4_34(Db4oUUID itemUUID)
 {
     this.itemUUID = itemUUID;
 }
Пример #22
0
 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();
 }
Пример #24
0
 public _ICodeBlock_122(Db4oIOExceptionTestCase _enclosing, Db4oUUID uuid)
 {
     this._enclosing = _enclosing;
     this.uuid       = uuid;
 }
Пример #25
0
 public sealed override object GetByUUID(Db4oUUID uuid)
 {
     return(GetByUUID(null, uuid));
 }