示例#1
0
 public static Env GetEnv(DB_ENV *evp)
 {
     if (evp == null)
     {
         return(null);
     }
     else
     {
         IntPtr gh = evp->api_internal;
         if (gh == IntPtr.Zero)
         {
             return(null);
         }
         else
         {
             return((Env)((GCHandle)gh).Target);
         }
     }
 }
 public Env(EnvCreateFlags flags): this() {
   DbRetVal ret;
   lock (rscLock) {
     RuntimeHelpers.PrepareConstrainedRegions();
     try { }
     finally {
       DB_ENV* evp;
       ret = LibDb.db_env_create(out evp, flags);
       if (ret == DbRetVal.SUCCESS) {
         this.evp = evp;
         evp->api_internal = (IntPtr)instanceHandle;
       }
     }
   }
   Util.CheckRetVal(ret);
 }
 void Disposed() {
   evp = null;
 }
 // called when creating wrapper for private (internal) environment of DB;
 // call must be synchronized on rscLock; db.Evp must be != null, not checked;
 internal void SetOwnerDatabase(Db db) {
   evp = db.GetEvp();
   databases.Insert(db);
   isOwnedByDb = true;
   // so that callbacks can refer back to the DbEnv instance
   instanceHandle = GCHandle.Alloc(this, GCHandleType.WeakTrackResurrection);
   evp->api_internal = (IntPtr)instanceHandle;
 }