Beispiel #1
0
        private void FromStream(Stream dataStream)
        {
            Debug.Assert(dataStream.CanSeek, "The provided data stream must support seek operations!");

            using (var binaryReader = new BinaryReader(dataStream))
            {
                Signature = binaryReader.ReadInt32();

                Reader baseReader;
                switch (Signature)
                {
                case 0x35424457:
                    baseReader = new WDB5.Reader <T>(dataStream);
                    break;

                case 0x32424457:
                    baseReader = new WDB2.Reader <T>(dataStream);
                    break;

                case 0x43424457:
                    baseReader = new WDBC.Reader <T>(dataStream);
                    break;

                default:
                    throw new ArgumentOutOfRangeException(Signature.ToString("X"));
                }

                baseReader.OnRecordLoaded += (index, record) => this[index] = (T)record;
                baseReader.Load();

                HasIndexTable  = baseReader.FileHeader.HasIndexTable;
                HasStringTable = baseReader.FileHeader.HasStringTable;
                IndexField     = baseReader.FileHeader.IndexField;
            }
        }
        private void FromStream(Stream dataStream)
        {
            using (var binaryReader = new BinaryReader(dataStream))
            {
                Signature = binaryReader.ReadInt32();

                Reader <T> fileReader;
                switch (Signature)
                {
                case 0x36424457:
                    fileReader = new WDB6.Reader <T>(dataStream);
                    break;

                case 0x35424457:
                    fileReader = new WDB5.Reader <T>(dataStream);
                    break;

                case 0x32424457:
                    fileReader = new WDB2.Reader <T>(dataStream);
                    break;

                case 0x43424457:
                    fileReader = new WDBC.Reader <T>(dataStream);
                    break;

                default:
                    throw new ArgumentOutOfRangeException(Signature.ToString("X"));
                }

                fileReader.OnRecordLoaded += (index, record) => this[index] = (T)record;
                fileReader.Load();

                HasIndexTable  = fileReader.FileHeader.HasIndexTable;
                HasStringTable = fileReader.FileHeader.HasStringTable;
                IndexField     = fileReader.FileHeader.IndexField;
            }
        }