Example #1
0
        public BerkeleyDtoResult Create([FromUri] BerkeleyDbType type, [FromUri] String flags)
        {
            ulong           handle   = 0;
            BerkeleyDbFlags bdbFlags = BerkeleyEnumParser.Flags(flags);

            IntPtr          pdb;
            IntPtr          penv  = DbenvInstance.Instance.Handle;
            BerkeleyDbError error = BDbMethods.Create(BDbOffsetOfInstance.Instance, penv, type, bdbFlags, out pdb);

            if (error == 0)
            {
                BDbMethods dbMethods = BDbMethods.GetMethods(type);
                var        db        = new DbHandle(pdb, dbMethods);
                handle = DbInstance.AddDb(db);
                if (handle == 0)
                {
                    dbMethods.Close(pdb, 0);
                    throw new HttpResponseException(HttpStatusCode.InternalServerError);
                }
            }

            return(new BerkeleyDtoResult(error, handle.ToString()));
        }
Example #2
0
 public DbHandle(IntPtr pdb, BDbMethods methods)
 {
     Handle  = pdb;
     Methods = methods;
 }