本文整理汇总了C#中IPersistent.OnStore方法的典型用法代码示例。如果您正苦于以下问题:C# IPersistent.OnStore方法的具体用法?C# IPersistent.OnStore怎么用?C# IPersistent.OnStore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPersistent
的用法示例。
在下文中一共展示了IPersistent.OnStore方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}