Ejemplo n.º 1
0
 public void FromNetworkResource(string host, string queryString)
 {
     using (var blte = new BLTE(host))
     {
         blte.Send(queryString);
         if (!blte.Failed)
         {
             FromStream(blte);
         }
     }
 }
Ejemplo n.º 2
0
Archivo: Root.cs Proyecto: Warpten/NGDP
        public void FromStream(string host, string queryString)
        {
            using (var blte = new BLTE(host))
            {
                blte.Send(queryString);
                if (blte.Failed)
                {
                    return;
                }

                using (var fileReader = new EndianBinaryReader(EndianBitConverter.Little, blte.ReadToEnd()))
                {
                    while (fileReader.BaseStream.Position < fileReader.BaseStream.Length)
                    {
                        var recordCount = fileReader.ReadInt32();

                        fileReader.BaseStream.Seek(4 + 4, SeekOrigin.Current); // Skip flags
                        // var contentFlags = fileReader.ReadInt32();
                        // var localeFlags = fileReader.ReadInt32();

                        var records = new Record[recordCount];
                        // var fileDataIndex = 0;

                        for (var i = 0; i < recordCount; ++i)
                        {
                            // ReSharper disable once UseObjectOrCollectionInitializer
                            records[i] = new Record();
                            // records[i].LocaleFlags = localeFlags;
                            // records[i].ContentFlags = contentFlags;

                            // records[i].FileDataID = fileDataIndex + fileReader.ReadInt32();
                            // fileDataIndex = records[i].FileDataID + 1;
                        }

                        fileReader.BaseStream.Seek(4 * recordCount, SeekOrigin.Current); // Skip FileDataIDs.

                        for (var i = 0; i < recordCount; ++i)
                        {
                            records[i].MD5 = ByteArrayComparer.Instance.GetHashCode(fileReader.ReadBytes(16));
                            var recordHash = fileReader.ReadUInt64();

                            Records[recordHash] = records[i];
                        }
                    }
                }
            }

            Loaded = true;
        }