internal DbEnv createDbEnv() { DbEnv env = new DbEnv(0); this.configureDbEnv(env, false); return(env); }
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); }
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_); } }
public Environment(string home, EnvironmentConfig config) { this.env_ = null; this.envClosed_ = true; this.env_ = config.openDbEnv(home); this.envClosed_ = false; this.config_ = config; }
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); }
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(); }
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); }
internal EnvironmentConfig(DbEnv env) : this() { this.SetFromDbEnv(env); }
internal Environment(DbEnv e) { this.env_ = e; this.envClosed_ = true; this.config_ = null; }