Esempio n. 1
0
        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);
        }
Esempio n. 2
0
 protected GenericStringBlock(GenericStringBlock other)
 {
     Used = other.Used;
     Data = other.Data;
     Id   = other.Id;
 }
Esempio n. 3
0
 public LabelBlock(GenericStringBlock genericStringBlock) : base(genericStringBlock)
 {
 }
Esempio n. 4
0
 public PropertyNameBlock(GenericStringBlock genericStringBlock) : base(genericStringBlock)
 {
 }