public static void WriteStringBlock(GenericStringBlock s) { string storagePath; switch (s) { case LabelBlock _: storagePath = DbControl.LabelPath; break; case StringBlock _: storagePath = DbControl.StringPath; break; case PropertyNameBlock _: storagePath = DbControl.PropertyNamePath; break; default: throw new NotSupportedException("Unsupported string-like block type."); } var buffer = new byte[DbControl.BlockByteSize[storagePath]]; Array.Copy(BitConverter.GetBytes(s.Used), buffer, 1); var strBytes = Encoding.UTF8.GetBytes(s.Data); var truncStrArray = new byte[32]; var truncationIndex = Math.Min(strBytes.Length, truncStrArray.Length); Array.Copy(strBytes, truncStrArray, truncationIndex); buffer[1] = (byte)strBytes.Length; Array.Copy(truncStrArray, 0, buffer, 2, truncationIndex); WriteBlock(storagePath, s.Id, buffer); }
protected GenericStringBlock(GenericStringBlock other) { Used = other.Used; Data = other.Data; Id = other.Id; }
public LabelBlock(GenericStringBlock genericStringBlock) : base(genericStringBlock) { }
public PropertyNameBlock(GenericStringBlock genericStringBlock) : base(genericStringBlock) { }