public BerkeleyDbError Open([FromUri] ulong handle, [FromUri] String name, [FromUri] String flags) { DbHandle db = GetDb(handle); BerkeleyDbOpenFlags openFlags = BerkeleyEnumParser.OpenFlags(flags); return(db.Methods.Open(db.Handle, name, openFlags)); }
public static EnvConfig ReadXmlFile() { var root = XElement.Load("envconfig.xml"); XElement xopen = root.Elements("open").Single(); XElement xdbhome = xopen.Elements("dbhome").Single(); bool useTempIfFault; Boolean.TryParse(xdbhome.Attribute("useTempIfFault").Value, out useTempIfFault); BerkeleyDbEnvOpen openFlags = BerkeleyEnumParser.EnvOpenFlags(xopen.Element("flags").Value.Trim()); XElement xclose = root.Elements("close").Single(); BerkeleyDbEnvClose closeFlags = BerkeleyEnumParser.EnvCloseFlags(xclose.Element("flags").Value.Trim()); return(new EnvConfig(xdbhome.Value.Trim(), useTempIfFault, openFlags, closeFlags)); }
public BerkeleyDtoResult OpenCursor([FromUri] ulong handle, [FromUri] String flags) { DbHandle db = GetDb(handle); BerkeleyDbCursorFlags cursorFlags = flags == null ? 0 : BerkeleyEnumParser.CursorFlags(flags); ulong cursorHandle = 0; IntPtr pdbc; BerkeleyDbError error = BDbcMethods.Create(BDbOffsetOfInstance.Instance, db.Handle, db.Methods.DbType, cursorFlags, out pdbc); if (error == 0) { DbcHandle dbc = new DbcHandle(pdbc, BDbcMethods.GetMethods(db.Methods.DbType)); cursorHandle = DbcInstance.AddDbc(dbc); if (cursorHandle == 0) { dbc.Methods.Close(dbc.Handle); throw new HttpResponseException(HttpStatusCode.InternalServerError); } } return(new BerkeleyDtoResult(error, cursorHandle.ToString())); }
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())); }