コード例 #1
0
        private static DatHeader ReadHeader(FileStream stream)
        {
            byte[] buffer = new byte[16];
            if (stream.Read(buffer, 0, buffer.Length) != buffer.Length)
            {
                throw new Exception("Unable to read prime header");
            }

            var result = new DatHeader()
            {
                message = (bufferType)BitConverter.ToInt64(buffer, 0),
                count   = BitConverter.ToInt32(buffer, 4),
                crc64   = BitConverter.ToInt64(buffer, 8)
            };

            return(result);
        }
コード例 #2
0
        private static void CreateCache(DatHeader header, List <byte[]> set)
        {
            switch (header.message)
            {
            case bufferType.domainCrcBuffer:
            {
                for (int i = 0; i < set[0].Length; i = i + 8)
                {
                    domains.Add(new CacheDomain()
                        {
                            Crc64 = BitConverter.ToUInt64(set[0], i)
                        });
                }
                break;
            }

            case bufferType.domainAccuracyBuffer:
            {
                for (int i = 0; i < set[0].Length; i = i + 2)
                {
                    domains[i / 2].Accuracy = BitConverter.ToInt16(set[0], i);
                }
                break;
            }

            case bufferType.domainFlagsBuffer:
            {
                for (int i = 0; i < set[0].Length; i = i + 8)
                {
                    var flags = new List <int>();
                    flags[0]             = BitConverter.ToChar(set[0], 0);
                    domains[i / 8].Flags = flags;
                }
                break;
            }
            }
        }