internal override void Marshall(Transaction trans, ObjectReference @ref, IWriteBuffer
                                        buffer, bool isMigrating, bool isNew)
        {
            VirtualAttributes   attr      = @ref.VirtualAttributes();
            ObjectContainerBase container = trans.Container();
            bool doAddIndexEntry          = isNew && container.MaintainsIndices();
            int  dbID           = 0;
            bool linkToDatabase = (attr != null && attr.i_database == null) ? true : !isMigrating;

            if (linkToDatabase)
            {
                Db4oDatabase db = ((IInternalObjectContainer)container).Identity();
                if (db == null)
                {
                    // can happen on early classes like Metaxxx, no problem
                    attr = null;
                }
                else
                {
                    if (attr.i_database == null)
                    {
                        attr.i_database = db;
                        // TODO: Should be check for ! client instead of instanceof
                        if (container is LocalObjectContainer)
                        {
                            attr.i_uuid     = container.GenerateTimeStampId();
                            doAddIndexEntry = true;
                        }
                    }
                    db = attr.i_database;
                    if (db != null)
                    {
                        dbID = db.GetID(trans);
                    }
                }
            }
            else
            {
                if (attr != null)
                {
                    dbID = attr.i_database.GetID(trans);
                }
            }
            buffer.WriteInt(dbID);
            if (attr == null)
            {
                buffer.WriteLong(0);
                return;
            }
            buffer.WriteLong(attr.i_uuid);
            if (doAddIndexEntry)
            {
                AddIndexEntry(trans, @ref.GetID(), attr.i_uuid);
            }
        }
示例#2
0
 public override long GenerateTimeStampId()
 {
     return(_parent.GenerateTimeStampId());
 }