/// <summary> /// Reallocates already allocated db item with specified content and produces reference to it. /// </summary> /// <param name="reference">Reference to already allocated item</param> /// <param name="newContent">Content of item to reallocate</param> /// <returns>Reference to the reallocated item</returns> public DbItemReference Reallocate(DbItemReference reference, byte[] newContent) { var item = new DbItem(newContent); if (item.GetAllocationType(_pageManager.PageSize) == AllocationType.SinglePage) { IPage page = _pageManager.FetchPage(reference.PageIndex); if (PageFormatter.GetPageHeader(page).SizeRange == item.SizeRange) { PageFormatter.RewriteFixedSizeItem(page, reference.ItemIndex, item); _pageManager.UpdatePage(page); return(reference); } Free(reference); return(AllocateSinglePage(item)); } Free(reference); return(AllocateMultiPage(item)); }