BerkeleyDB.SecondaryBTreeDatabase.Config C# (CSharp) Method

Config() private method

private Config ( BerkeleyDB.SecondaryBTreeDatabaseConfig cfg ) : void
cfg BerkeleyDB.SecondaryBTreeDatabaseConfig
return void
        private void Config(SecondaryBTreeDatabaseConfig cfg)
        {
            base.Config((SecondaryDatabaseConfig)cfg);
            db.set_flags(cfg.flags);
            if (cfg.Compare != null)
                Compare = cfg.Compare;
            if (cfg.PrefixCompare != null)
                PrefixCompare = cfg.PrefixCompare;
            if (cfg.DuplicateCompare != null)
                DupCompare = cfg.DuplicateCompare;
            if (cfg.minkeysIsSet)
                db.set_bt_minkey(cfg.MinKeysPerPage);
        }

Usage Example

        /// <summary>
        /// Instantiate a new SecondaryBTreeDatabase object, open the
        /// database represented by <paramref name="Filename"/> and associate
        /// the database with the
        /// <see cref="SecondaryDatabaseConfig.Primary">primary index</see>.
        /// </summary>
        /// <remarks>
        /// <para>
        /// If both <paramref name="Filename"/> and
        /// <paramref name="DatabaseName"/> are null, the database is strictly
        /// temporary and cannot be opened by any other thread of control, thus
        /// the database can only be accessed by sharing the single database
        /// object that created it, in circumstances where doing so is safe. If
        /// <paramref name="Filename"/> is null and
        /// <paramref name="DatabaseName"/> is non-null, the database can be
        /// opened by other threads of control and be replicated to client
        /// sites in any replication group.
        /// </para>
        /// <para>
        /// If <paramref name="txn"/> is null, but
        /// <see cref="DatabaseConfig.AutoCommit"/> is set, the operation
        /// is implicitly transaction protected. Transactionally
        /// protected operations on a database object requires the object itself
        /// be transactionally protected during its open. The
        /// transaction must be committed before the object is closed.
        /// </para>
        /// </remarks>
        /// <param name="Filename">
        /// The name of an underlying file used to back the
        /// database. In-memory databases never intended to be preserved on disk
        /// may be created by setting this parameter to null.
        /// </param>
        /// <param name="DatabaseName">
        /// This parameter allows applications to have multiple databases in a
        /// single file. Although no DatabaseName needs to be specified, it is
        /// an error to attempt to open a second database in a file that was not
        /// initially created using a database name.
        /// </param>
        /// <param name="cfg">The database's configuration</param>
        /// <param name="txn">
        /// If the operation is part of an application-specified transaction,
        /// <paramref name="txn"/> is a Transaction object returned from
        /// <see cref="DatabaseEnvironment.BeginTransaction"/>; if
        /// the operation is part of a Berkeley DB Concurrent Data Store group,
        /// <paramref name="txn"/> is a handle returned from
        /// <see cref="DatabaseEnvironment.BeginCDSGroup"/>; otherwise null.
        /// </param>
        /// <returns>A new, open database object</returns>
        public static SecondaryBTreeDatabase Open(
            string Filename, string DatabaseName,
            SecondaryBTreeDatabaseConfig cfg, Transaction txn)
        {
            SecondaryBTreeDatabase ret = new SecondaryBTreeDatabase(cfg.Env, 0);

            ret.Config(cfg);
            ret.db.open(Transaction.getDB_TXN(txn), Filename,
                        DatabaseName, cfg.DbType.getDBTYPE(), cfg.openFlags, 0);
            ret.isOpen     = true;
            ret.doAssocRef = new BDB_AssociateDelegate(
                SecondaryDatabase.doAssociate);
            cfg.Primary.db.associate(Transaction.getDB_TXN(txn),
                                     ret.db, ret.doAssocRef, cfg.assocFlags);

            if (cfg.ForeignKeyDatabase != null)
            {
                if (cfg.OnForeignKeyDelete == ForeignKeyDeleteAction.NULLIFY)
                {
                    ret.doNullifyRef =
                        new BDB_AssociateForeignDelegate(doNullify);
                }
                else
                {
                    ret.doNullifyRef = null;
                }
                cfg.ForeignKeyDatabase.db.associate_foreign(
                    ret.db, ret.doNullifyRef, cfg.foreignFlags);
            }
            return(ret);
        }
All Usage Examples Of BerkeleyDB.SecondaryBTreeDatabase::Config