Example #1
0
        internal DbEnv createDbEnv()
        {
            DbEnv env = new DbEnv(0);

            this.configureDbEnv(env, false);
            return(env);
        }
Example #2
0
        internal DbEnv openDbEnv(string home)
        {
            DbEnv env = this.createDbEnv();

            try
            {
                if (home == null)
                {
                    this.Private         = true;
                    this.Create          = true;
                    this.InitializeCache = true;
                }
                env.open(home, this.flags_, this.mode_);
            }
            catch (Exception exception)
            {
                try
                {
                    env.close(0);
                }
                catch (Exception)
                {
                }
                throw exception;
            }
            return(env);
        }
Example #3
0
 internal void configureDbEnv(DbEnv env, bool isOpen)
 {
     if (!isOpen)
     {
         env.set_cachesize(0, (uint)this.cachesize_, this.nCaches_);
     }
     if (this.dataDirs_ != null)
     {
         foreach (string str in this.dataDirs_)
         {
             env.set_data_dir(str);
         }
     }
     if (this.encryptPassword_ != null)
     {
         env.set_encrypt(this.encryptPassword_, 0);
     }
     if (this.errPrefix_ != null)
     {
         env.set_errpfx(this.errPrefix_);
     }
     if ((this.errCallback_ != null) || (this.errWriter_ != null))
     {
         env.set_errcall(this.dbenvDelegate_);
     }
 }
Example #4
0
 public Environment(string home, EnvironmentConfig config)
 {
     this.env_       = null;
     this.envClosed_ = true;
     this.env_       = config.openDbEnv(home);
     this.envClosed_ = false;
     this.config_    = config;
 }
Example #5
0
 public void Dispose()
 {
     if (!this.envClosed_)
     {
         this.envClosed_ = true;
         if (DbEnv.getCPtr(this.env_) != IntPtr.Zero)
         {
             this.env_.close(0);
         }
     }
     if (this.env_ != null)
     {
         this.env_.Dispose();
     }
     GC.SuppressFinalize(this);
 }
Example #6
0
        internal void SetFromDbEnv(DbEnv env)
        {
            string str;

            this.flags_     = env.get_open_flags();
            this.cachesize_ = (int)((0x40000000 * env.get_cachesize_gbytes()) + env.get_cachesize_bytes());
            this.nCaches_   = (int)env.get_cachesize_ncache();
            StringArrayIterator iterator = env.get_data_dirs();
            ArrayList           list     = new ArrayList();

            while ((str = iterator.next()) != null)
            {
                list.Add(str);
            }
            this.dataDirs_  = (string[])list.ToArray(typeof(string));
            this.errPrefix_ = env.get_errpfx();
        }
Example #7
0
        public static void Remove(string home, bool force, EnvironmentConfig config)
        {
            DbEnv env   = config.createDbEnv();
            uint  flags = 0;

            if (force)
            {
                flags |= (uint)DbXml.DB_FORCE;
            }
            if (config.UseEnvironment)
            {
                flags |= (uint)DbXml.DB_USE_ENVIRON;
            }
            if (config.UseEnvironmentRoot)
            {
                flags |= (uint)DbXml.DB_USE_ENVIRON_ROOT;
            }
            env.remove(home, flags);
        }
Example #8
0
 internal EnvironmentConfig(DbEnv env) : this()
 {
     this.SetFromDbEnv(env);
 }
Example #9
0
 internal Environment(DbEnv e)
 {
     this.env_       = e;
     this.envClosed_ = true;
     this.config_    = null;
 }