Exemplo n.º 1
0
        private Db4objects.Db4o.Ext.Db4oDatabase Query(Transaction trans, bool constrainByUUID
                                                       )
        {
            ObjectContainerBase stream = trans.Container();
            IQuery q = stream.Query(trans);

            q.Constrain(GetType());
            if (constrainByUUID)
            {
                q.Descend(CreationtimeField).Constrain(i_uuid);
            }
            IObjectSet objectSet = q.Execute();

            while (objectSet.HasNext())
            {
                Db4objects.Db4o.Ext.Db4oDatabase storedDatabase = (Db4objects.Db4o.Ext.Db4oDatabase
                                                                   )objectSet.Next();
                stream.Activate(null, storedDatabase, new FixedActivationDepth(4));
                if (storedDatabase.Equals(this))
                {
                    return(storedDatabase);
                }
            }
            return(null);
        }
Exemplo n.º 2
0
        /// <summary>make sure this Db4oDatabase is stored.</summary>
        /// <remarks>make sure this Db4oDatabase is stored. Return the ID.</remarks>
        public virtual int Bind(Transaction trans)
        {
            ObjectContainerBase stream = trans.Container();

            Db4objects.Db4o.Ext.Db4oDatabase stored = (Db4objects.Db4o.Ext.Db4oDatabase)stream
                                                      .Db4oTypeStored(trans, this);
            if (stored == null)
            {
                return(StoreAndGetId(trans));
            }
            if (stored == this)
            {
                return(stream.GetID(trans, this));
            }
            if (i_uuid == 0)
            {
                i_uuid = stored.i_uuid;
            }
            stream.ShowInternalClasses(true);
            try
            {
                int id = stream.GetID(trans, stored);
                stream.Bind(trans, this, id);
                return(id);
            }
            finally
            {
                stream.ShowInternalClasses(false);
            }
        }
Exemplo n.º 3
0
 public virtual bool IsOlderThan(Db4objects.Db4o.Ext.Db4oDatabase peer)
 {
     if (peer == this)
     {
         throw new ArgumentException();
     }
     if (i_uuid != peer.i_uuid)
     {
         return(i_uuid < peer.i_uuid);
     }
     // the above logic has failed, both are the same
     // age but we still want to distinguish in some
     // way, to have an order in the ReplicationRecord
     // The following is arbitrary, it only needs to
     // be repeatable.
     // Let's distinguish by signature length
     if (i_signature.Length != peer.i_signature.Length)
     {
         return(i_signature.Length < peer.i_signature.Length);
     }
     for (int i = 0; i < i_signature.Length; i++)
     {
         if (i_signature[i] != peer.i_signature[i])
         {
             return(i_signature[i] < peer.i_signature[i]);
         }
     }
     // This should never happen.
     // FIXME: Add a message and move to Messages.
     //
     throw new Exception();
 }
Exemplo n.º 4
0
 /// <summary>find a Db4oDatabase with the same signature as this one</summary>
 public virtual Db4objects.Db4o.Ext.Db4oDatabase Query(Transaction trans)
 {
     // showInternalClasses(true);  has to be set for this method to be successful
     if (i_uuid > 0)
     {
         // try fast query over uuid (creation time) first
         Db4objects.Db4o.Ext.Db4oDatabase res = Query(trans, true);
         if (res != null)
         {
             return(res);
         }
     }
     // if not found, try to find with signature
     return(Query(trans, false));
 }
Exemplo n.º 5
0
 /// <summary>comparison by signature.</summary>
 /// <remarks>comparison by signature.</remarks>
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj == null || this.GetType() != obj.GetType())
     {
         return(false);
     }
     Db4objects.Db4o.Ext.Db4oDatabase other = (Db4objects.Db4o.Ext.Db4oDatabase)obj;
     if (null == other.i_signature || null == this.i_signature)
     {
         return(false);
     }
     return(Arrays4.Equals(other.i_signature, this.i_signature));
 }