Beispiel #1
0
        public Database(IEnumerable <Stream> streams)
        {
            foreach (var stream in streams)
            {
                InitDatabaseStream(stream);
            }

            // Instantiate buffer manager
            _bufferManager = new BufferManager(this);

            // Read boot page properties
            var bootPage = GetBootPage();

            Name = bootPage.DatabaseName;
            ID   = bootPage.DBID;
            var collation = Collations.GetByCollationId((int)(bootPage.CollationId >> 32));

            DefaultCollation = collation.Name;
            Encoding         = Collations.GetEncodingForCollation(collation);
            // Parse vital base tables
            BaseTables = new BaseTableData(this);

            // Startup dmv generator
            Dmvs = new DmvGenerator(this);
        }
Beispiel #2
0
        /// <summary>
        /// Instantiates a new database. Each data file that's part of the database must be included in the files parameter.
        /// The order of the files is irrelevant.
        /// </summary>
        public Database(IEnumerable <string> files)
        {
            foreach (string file in files)
            {
                using (var fs = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    byte[] fileHeaderBytes = new byte[8192];
                    fs.Read(fileHeaderBytes, 0, 8192);

                    // This is kindy hackish as "this" isn't operational yet. As such, any calls to "this" will fail.
                    // We know however that, currently, FileHeaderPage doesn't use the reference. Should be changed
                    // later on.
                    var fileHeaderPage = new FileHeaderPage(fileHeaderBytes, this);

                    // Store reference to data file
                    Files.Add(fileHeaderPage.FileID, new DataFile(fileHeaderPage.FileID, file));
                }
            }

            // Instantiate buffer manager
            bufferManager = new BufferManager(this);

            // Read boot page properties
            var bootPage = GetBootPage();

            Name = bootPage.DatabaseName;
            ID   = bootPage.DBID;

            // Parse vital base tables
            BaseTables = new BaseTableData(this);

            // Startup dmv generator
            Dmvs = new DmvGenerator(this);
        }
Beispiel #3
0
        /// <summary>
        /// Instantiates a new database. Each data file that's part of the database must be included in the files parameter.
        /// The order of the files is irrelevant.
        /// </summary>
        public Database(IEnumerable <string> files)
        {
            foreach (var file in files)
            {
                var fs = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read);

                InitDatabaseStream(fs, file);
            }

            // Instantiate buffer manager
            _bufferManager = new BufferManager(this);

            // Read boot page properties
            var bootPage = GetBootPage();

            Name = bootPage.DatabaseName;
            ID   = bootPage.DBID;
            var collation = Collations.GetByCollationId((int)(bootPage.CollationId >> 32));

            DefaultCollation = collation.Name;
            Encoding         = Collations.GetEncodingForCollation(collation);
            // Parse vital base tables
            BaseTables = new BaseTableData(this);

            // Startup dmv generator
            Dmvs = new DmvGenerator(this);
        }