当前位置: 首页>>代码示例>>C#>>正文


C# IPersistent.AssignOid方法代码示例

本文整理汇总了C#中IPersistent.AssignOid方法的典型用法代码示例。如果您正苦于以下问题:C# IPersistent.AssignOid方法的具体用法?C# IPersistent.AssignOid怎么用?C# IPersistent.AssignOid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPersistent的用法示例。


在下文中一共展示了IPersistent.AssignOid方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DeallocateObject

 public virtual void DeallocateObject(IPersistent obj)
 {
     lock (this)
     {
         lock (objectCache)
         {
             int oid = obj.Oid;
             if (oid == 0)
             {
                 return;
             }
             long pos = GetPos(oid);
             objectCache.Remove(oid);
             int offs = (int) pos & (Page.pageSize - 1);
             if ((offs & (dbFreeHandleFlag | dbPageObjectFlag)) != 0)
             {
                 throw new StorageError(StorageError.DELETED_OBJECT);
             }
             Page pg = pool.GetPage(pos - offs);
             offs &= ~ dbFlagsMask;
             int size = ObjectHeader.GetSize(pg.data, offs);
             pool.Unfix(pg);
             FreeId(oid);
             if ((pos & dbModifiedFlag) != 0)
             {
                 Free(pos & ~ dbFlagsMask, size);
             }
             else
             {
                 CloneBitmap(pos, size);
             }
             obj.AssignOid(this, 0, false);
         }
     }
 }
开发者ID:kjk,项目名称:tenderbase,代码行数:35,代码来源:StorageImpl.cs

示例2: StoreObject0

        private void StoreObject0(IPersistent obj)
        {
            obj.OnStore();
            int oid = obj.Oid;
            bool newObject = false;
            if (oid == 0)
            {
                oid = AllocateId();
                if (!obj.Deleted)
                {
                    objectCache.Put(oid, obj);
                }
                obj.AssignOid(this, oid, false);
                newObject = true;
            }
            else if (obj.Modified)
            {
                objectCache.ClearDirty(oid);
            }
            byte[] data = PackObject(obj);
            long pos;
            int newSize = ObjectHeader.GetSize(data, 0);
            if (newObject || (pos = GetPos(oid)) == 0)
            {
                pos = Allocate(newSize, 0);
                SetPos(oid, pos | dbModifiedFlag);
            }
            else
            {
                int offs = (int) pos & (Page.pageSize - 1);
                if ((offs & (dbFreeHandleFlag | dbPageObjectFlag)) != 0)
                {
                    throw new StorageError(StorageError.DELETED_OBJECT);
                }

                Page pg = pool.GetPage(pos - offs);
                offs &= ~ dbFlagsMask;
                int size = ObjectHeader.GetSize(pg.data, offs);
                pool.Unfix(pg);
                if ((pos & dbModifiedFlag) == 0)
                {
                    CloneBitmap(pos & ~ dbFlagsMask, size);
                    pos = Allocate(newSize, 0);
                    SetPos(oid, pos | dbModifiedFlag);
                }
                else
                {
                    if (((newSize + dbAllocationQuantum - 1) & ~ (dbAllocationQuantum - 1)) > ((size + dbAllocationQuantum - 1) & ~ (dbAllocationQuantum - 1)))
                    {
                        long newPos = Allocate(newSize, 0);
                        CloneBitmap(pos & ~ dbFlagsMask, size);
                        Free(pos & ~ dbFlagsMask, size);
                        pos = newPos;
                        SetPos(oid, pos | dbModifiedFlag);
                    }
                    else if (newSize < size)
                    {
                        ObjectHeader.SetSize(data, 0, size);
                    }
                }
            }
            modified = true;
            pool.Put(pos & ~ dbFlagsMask, data, newSize);
        }
开发者ID:kjk,项目名称:tenderbase,代码行数:64,代码来源:StorageImpl.cs

示例3: AssignOid

 internal void AssignOid(IPersistent obj, int oid)
 {
     obj.AssignOid(this, oid, false);
 }
开发者ID:kjk,项目名称:tenderbase,代码行数:4,代码来源:StorageImpl.cs

示例4: LoadStub

        internal IPersistent LoadStub(int oid, IPersistent obj, Type cls)
        {
            long pos = GetPos(oid);
            if ((pos & (dbFreeHandleFlag | dbPageObjectFlag)) != 0)
            {
                throw new StorageError(StorageError.DELETED_OBJECT);
            }

            byte[] body = pool.Get(pos & ~ dbFlagsMask);
            ClassDescriptor desc;
            int typeOid = ObjectHeader.GetType(body, 0);
            if (typeOid == 0)
            {
                //UPGRADE_TODO: Method 'java.util.HashMap.get' was converted to 'System.Collections.Hashtable.Item' which has a different behavior.
                desc = (ClassDescriptor) classDescMap[cls];
            }
            else
            {
                desc = FindClassDescriptor(typeOid);
            }

            if (obj == null)
            {
                obj = (IPersistent) desc.NewInstance();
                objectCache.Put(oid, obj);
            }
            obj.AssignOid(this, oid, false);
            if (obj is FastSerializable)
            {
                ((FastSerializable) obj).Unpack(body, ObjectHeader.Sizeof, encoding);
            }
            else
            {
                try
                {
                    UnpackObject(obj, desc, obj.RecursiveLoading, body, ObjectHeader.Sizeof, obj);
                }
                catch (System.Exception x)
                {
                    throw new StorageError(StorageError.ACCESS_VIOLATION, x);
                }
            }
            obj.OnLoad();
            return obj;
        }
开发者ID:kjk,项目名称:tenderbase,代码行数:45,代码来源:StorageImpl.cs

示例5: MakePersistent

        public virtual int MakePersistent(IPersistent obj)
        {
            lock (this)
            {
                if (!opened)
                    throw new StorageError(StorageError.STORAGE_NOT_OPENED);

                if (obj == null)
                    return 0;

                int oid = obj.Oid;
                if (oid != 0)
                    return oid;

                lock (objectCache)
                {
                    oid = AllocateId();
                    obj.AssignOid(this, oid, false);
                    SetPos(oid, 0);
                    objectCache.Put(oid, obj);
                    obj.Modify();
                    return oid;
                }
            }
        }
开发者ID:kjk,项目名称:tenderbase,代码行数:25,代码来源:StorageImpl.cs


注:本文中的IPersistent.AssignOid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。