internal static byte[] GetMarker(long itemsInList) { if (itemsInList <= 15) { return new[] { (byte)(0x90 + itemsInList) } } ; var output = new List <byte>(); if (itemsInList <= 0xFF) { output.Add(0xD4); } else if (itemsInList <= 0xFFFF) { output.Add(0xD5); } else if (itemsInList <= uint.MaxValue) { output.Add(0xD6); } if (itemsInList > uint.MaxValue) { throw new ArgumentOutOfRangeException(nameof(itemsInList), itemsInList, "Too many items in the list!"); } output.AddRange(PackStream.ConvertSizeToBytes(itemsInList)); return(output.ToArray()); }
private static byte[] GenerateChunkHeader(int length) { return(PackStream.ConvertSizeToBytes(length, 2)); }