Пример #1
0
            private static int GetNumberOfFields(byte[] bytes)
            {
                if (bytes[0] >= 0xB0 && bytes[0] <= 0xBF)
                {
                    return(bytes[0] - 0xB0);
                }

                if (bytes[0] == 0xDC)
                {
                    return(bytes[1]);
                }

                if (bytes[0] == 0xDD)
                {
                    var markerSize = bytes.Skip(1).Take(2).ToArray();
                    return(int.Parse(PackStreamBitConverter.ToString(markerSize).Replace("-", ""), NumberStyles.HexNumber));
                }

                throw new ArgumentOutOfRangeException(nameof(bytes), bytes[0], "Unknown Marker");
            }
Пример #2
0
            private static int GetNumberOfElements(byte[] content)
            {
                if (content[0] >= 0x90 && content[0] <= 0x9F)
                {
                    return(content[0] - 0x90);
                }

                if (content[0] == 0xD4)
                {
                    return(content[1]);
                }

                if (content[0] == 0xD5)
                {
                    return(int.Parse(PackStreamBitConverter.ToString(content.Skip(1).Take(2).ToArray()).Replace("-", ""), NumberStyles.HexNumber));
                }

                if (content[0] == 0xD6)
                {
                    return(int.Parse(PackStreamBitConverter.ToString(content.Skip(1).Take(4).ToArray()).Replace("-", ""), NumberStyles.HexNumber));
                }

                throw new ArgumentException("Unknown marker", nameof(content));
            }