public static void WriteRelationBlock(RelationBlock e) { var buffer = new byte[DbControl.BlockByteSize[DbControl.RelationPath]]; Array.Copy(BitConverter.GetBytes(e.Used), buffer, 1); Array.Copy(BitConverter.GetBytes(e.FirstNodeId), 0, buffer, 1, 4); Array.Copy(BitConverter.GetBytes(e.SecondNodeId), 0, buffer, 5, 4); Array.Copy(BitConverter.GetBytes(e.FirstNodePreviousRelationId), 0, buffer, 9, 4); Array.Copy(BitConverter.GetBytes(e.FirstNodeNextRelation), 0, buffer, 13, 4); Array.Copy(BitConverter.GetBytes(e.SecondNodePreviousRelationId), 0, buffer, 17, 4); Array.Copy(BitConverter.GetBytes(e.SecondNodeNextRelation), 0, buffer, 21, 4); Array.Copy(BitConverter.GetBytes(e.FirstPropertyId), 0, buffer, 25, 4); Array.Copy(BitConverter.GetBytes(e.LabelId), 0, buffer, 29, 4); WriteBlock(DbControl.RelationPath, e.RelationId, buffer); }
public static RelationBlock ReadRelationBlock(int relationId) { var buffer = new byte[DbControl.BlockByteSize[DbControl.RelationPath]]; ReadBlock(DbControl.RelationPath, relationId, buffer); RelationBlock e = new RelationBlock { Used = BitConverter.ToBoolean(buffer, 0), FirstNodeId = BitConverter.ToInt32(buffer.Skip(1).Take(4).ToArray(), 0), SecondNodeId = BitConverter.ToInt32(buffer.Skip(5).Take(4).ToArray(), 0), FirstNodePreviousRelationId = BitConverter.ToInt32(buffer.Skip(9).Take(4).ToArray(), 0), FirstNodeNextRelation = BitConverter.ToInt32(buffer.Skip(13).Take(4).ToArray(), 0), SecondNodePreviousRelationId = BitConverter.ToInt32(buffer.Skip(17).Take(4).ToArray(), 0), SecondNodeNextRelation = BitConverter.ToInt32(buffer.Skip(21).Take(4).ToArray(), 0), FirstPropertyId = BitConverter.ToInt32(buffer.Skip(25).Take(4).ToArray(), 0), LabelId = BitConverter.ToInt32(buffer.Skip(29).Take(4).ToArray(), 0), RelationId = relationId }; return(e); }