public void StreamDoneIndex(IO.EndianStream s) { switch (IndexSize) { case sizeof(byte): s.StreamSignature((byte)DoneIndex); break; case sizeof(ushort): s.StreamSignature((ushort)DoneIndex); break; case sizeof(uint): s.StreamSignature((uint)DoneIndex); break; default: throw new KSoft.Debug.UnreachableException(IndexSize.ToString()); } }
public void StreamCapacity(IO.EndianStream s, ref int capacity) { if (!SerializeCapacity) { return; } switch (IndexSize) { case sizeof(byte): byte cap8 = (byte)capacity; s.Stream(ref cap8); capacity = cap8; break; case sizeof(ushort): ushort cap16 = (ushort)capacity; s.Stream(ref cap16); capacity = cap16; break; case sizeof(int): s.Stream(ref capacity); break; default: throw new KSoft.Debug.UnreachableException(IndexSize.ToString()); } }
public string FormatIndexSize() { // Less than a KB? if (IndexSize < 1024) { return(IndexSize.ToString("0", CultureInfo.CurrentCulture) + "b"); } // Less than an MB? else if (IndexSize < (1024 * 1024)) { return((IndexSize / (double)1024).ToString("0.00", CultureInfo.CurrentCulture) + "KB"); } // Less than a GB? else if (IndexSize < (1024 * 1024 * 1024)) { return((IndexSize / (double)(1024 * 1024)).ToString("0.00", CultureInfo.CurrentCulture) + "MB"); } return((IndexSize / (double)(1024 * 1024 * 1024)).ToString("0.00", CultureInfo.CurrentCulture) + "GB"); }