Exemple #1
0
        public static BDbMethods GetMethods(BerkeleyDbType dbType)
        {
            BDbMethods methods = GetMethodsInternal(dbType);

            if (methods == null)
            {
                throw new InvalidOperationException("must call DbMethods.Create");
            }
            return(methods);
        }
        public static BerkeleyDbError Create(BDbOffsetOf offsetOf, IntPtr pdb, BerkeleyDbType dbType, BerkeleyDbCursorFlags flags, out IntPtr pdbc)
        {
            BDbMethods      dbMethods = BDbMethods.GetMethods(dbType);
            BerkeleyDbError error     = dbMethods.Cursor(pdb, flags, out pdbc);

            if (error == 0)
            {
                CreateMethods(dbType, pdbc, offsetOf);
            }
            return(error);
        }
Exemple #3
0
        public static BerkeleyDbError Create(BDbOffsetOf offsetOf, IntPtr penv, BerkeleyDbType dbType, BerkeleyDbFlags flags, out IntPtr pdb)
        {
            var error = (BerkeleyDbError)db_create(out pdb, penv, 0);

            if (error != 0)
            {
                return(error);
            }

            BDbMethods methods = CreateMethods(dbType, pdb, offsetOf);

            error = (BerkeleyDbError)methods.SetFlags(pdb, flags);
            if (error != 0 && pdb != IntPtr.Zero)
            {
                methods.Close(pdb, 0);
                pdb = IntPtr.Zero;
            }
            return(error);
        }
Exemple #4
0
        private static BDbMethods CreateMethods(BerkeleyDbType dbType, IntPtr pdb, BDbOffsetOf offsetOf)
        {
            BDbMethods dbMethods = GetMethodsInternal(dbType);

            if (dbMethods == null)
            {
                lock (typeof(BDbMethods))
                {
                    dbMethods = GetMethodsInternal(dbType);
                    if (dbMethods == null)
                    {
                        dbMethods = new BDbMethods(pdb, offsetOf, dbType);
                        switch (dbType)
                        {
                        case BerkeleyDbType.DB_BTREE:
                            _btree = dbMethods;
                            break;

                        case BerkeleyDbType.DB_HASH:
                            _hash = dbMethods;
                            break;

                        case BerkeleyDbType.DB_RECNO:
                            _recno = dbMethods;
                            break;

                        case BerkeleyDbType.DB_QUEUE:
                            _queue = dbMethods;
                            break;

                        case BerkeleyDbType.DB_UNKNOWN:
                            _unknown = dbMethods;
                            break;

                        case BerkeleyDbType.DB_HEAP:
                            _heap = dbMethods;
                            break;
                        }
                    }
                }
            }
            return(dbMethods);
        }
 private static BDbMethods CreateMethods(BerkeleyDbType dbType, IntPtr pdb, BDbOffsetOf offsetOf)
 {
     BDbMethods dbMethods = GetMethodsInternal(dbType);
     if (dbMethods == null)
     {
         lock (typeof(BDbMethods))
         {
             dbMethods = GetMethodsInternal(dbType);
             if (dbMethods == null)
             {
                 dbMethods = new BDbMethods(pdb, offsetOf, dbType);
                 switch (dbType)
                 {
                     case BerkeleyDbType.DB_BTREE:
                         _btree = dbMethods;
                         break;
                     case BerkeleyDbType.DB_HASH:
                         _hash = dbMethods;
                         break;
                     case BerkeleyDbType.DB_RECNO:
                         _recno = dbMethods;
                         break;
                     case BerkeleyDbType.DB_QUEUE:
                         _queue = dbMethods;
                         break;
                     case BerkeleyDbType.DB_UNKNOWN:
                         _unknown = dbMethods;
                         break;
                     case BerkeleyDbType.DB_HEAP:
                         _heap = dbMethods;
                         break;
                 }
             }
         }
     }
     return dbMethods;
 }
Exemple #6
0
 public DbHandle(IntPtr pdb, BDbMethods methods)
 {
     Handle = pdb;
     Methods = methods;
 }