Esempio n. 1
0
#pragma warning restore CA1825 // Avoid zero-length array allocations.

        public static string DotNetStr(DbRetCode ret)
        {
            if (ret > DotNetLowError && ret <= (DotNetLowError + dotNetStr.Length))
            {
                return(dotNetStr[(int)ret - (int)DotNetLowError - 1]);
            }
            else
            {
                return(UnknownStr(ret));
            }
        }
Esempio n. 2
0
 public static void CheckRetCode(DbRetCode ret)
 {
     if (ret != DbRetCode.SUCCESS)
     {
         string errStr;
         if (ret > MdbLowError && ret <= DbRetCode.LAST_ERRCODE)
         {
             errStr = DbLib.mdb_strerror(ret);
         }
         else
         {
             errStr = DotNetStr(ret);
         }
         throw new LmdbException(ret, errStr);
     }
 }
Esempio n. 3
0
        /// <summary>Constructor.</summary>
        /// <param name="config">Configuration to use.</param>
        public LmdbEnvironment(LmdbEnvironmentConfiguration config = null)
        {
            // so that we can refer back to the Environment instance
            instanceHandle = GCHandle.Alloc(this, GCHandleType.WeakTrackResurrection);

            DbRetCode ret = DbLib.mdb_env_create(out IntPtr envHandle);

            if (ret == DbRetCode.SUCCESS)
            {
                var ret2 = DbLib.mdb_env_set_userctx(envHandle, (IntPtr)instanceHandle);
                if (ret2 == DbRetCode.SUCCESS)
                {
                    this.env = envHandle;
                }
                else
                {
                    ret = ret2;
                    DbLib.mdb_env_close(envHandle);
                }
            }
            ErrorUtil.CheckRetCode(ret);

            if (config != null)
            {
                this.autoReduceMapSizeIn32BitProcess = config.AutoReduceMapSizeIn32BitProcess;
                if (config.MapSize.HasValue)
                {
                    this.SetMapSize(config.MapSize.Value);
                }
                if (config.MaxDatabases.HasValue)
                {
                    this.MaxDatabases = config.MaxDatabases.Value;
                }
                if (config.MaxReaders.HasValue)
                {
                    this.MaxReaders = config.MaxReaders.Value;
                }
            }
        }
Esempio n. 4
0
 public static string UnknownStr(DbRetCode ret)
 {
     return($"Unknown LMDB error code: {ret}.");
 }
Esempio n. 5
0
        public static string mdb_strerror(DbRetCode error)
        {
            IntPtr errStr = _mdb_strerror((int)error);

            return(Marshal.PtrToStringAnsi(errStr));
        }
Esempio n. 6
0
 /// <summary>Constructor.</summary>
 /// <param name="errorCode">Native error code.</param>
 public LmdbException(DbRetCode errorCode, string message) : base(message)
 {
     this.errorCode = errorCode;
 }
Esempio n. 7
0
 /// <summary>Constructor.</summary>
 /// <param name="errorCode">Native error code.</param>
 public LmdbException(DbRetCode errorCode)
 {
     this.errorCode = errorCode;
 }