Example #1
0
        /// <summary>
        /// 初始化MySQL实例
        /// </summary>
        private MySQL()
        {
            using (SecureString Secure = SecureAccessProvider.GetMySQLAccessCredential(Package.Current))
            {
                IntPtr Bstr             = Marshal.SecureStringToBSTR(Secure);
                string AccessCredential = Marshal.PtrToStringBSTR(Bstr);

                try
                {
                    ConnectionPool = new SQLConnectionPool <MySqlConnection>($"{AccessCredential}CharSet=utf8mb4;Database=FeedBackDataBase;", 2, 1);
                }
                finally
                {
                    Marshal.ZeroFreeBSTR(Bstr);
                    unsafe
                    {
                        fixed(char *ClearPtr = AccessCredential)
                        {
                            for (int i = 0; i < AccessCredential.Length; i++)
                            {
                                ClearPtr[i] = '\0';
                            }
                        }
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// 初始化SQLite的实例
        /// </summary>
        private SQLite()
        {
            SQLitePCL.Batteries_V2.Init();
            SQLitePCL.raw.sqlite3_win32_set_directory(1, ApplicationData.Current.LocalFolder.Path);
            SQLitePCL.raw.sqlite3_win32_set_directory(2, ApplicationData.Current.TemporaryFolder.Path);

            ConnectionPool = new SQLConnectionPool <SqliteConnection>("Filename=RX_Sqlite.db;", 2, 0);

            InitializeDatabase();
        }
Example #3
0
        /// <summary>
        /// 调用此方法以注销数据库连接
        /// </summary>
        public void Dispose()
        {
            if (!IsDisposed)
            {
                IsDisposed = true;

                ConnectionPool.Dispose();
                ConnectionPool = null;
                SQL            = null;

                GC.SuppressFinalize(this);
            }
        }