Exemple #1
0
        ///////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Creates and initializes the default log event handler.
        /// </summary>
        private static void InitializeDefaultHandler()
        {
            lock (syncRoot)
            {
                if (_defaultHandler == null)
                {
                    _defaultHandler = new SQLiteLogEventHandler(LogEventHandler);
                }
            }
        }
Exemple #2
0
        public void SubscribeUnsubscribeLog()
        {
            int             logCount      = 0;
            SQLiteErrorCode lastErrorCode = SQLiteErrorCode.Ok;

            using (SQLiteConnection conn = new SQLiteConnection(m_csb.ConnectionString))
            {
                conn.Open();

                try
                {
                    conn.Execute(@"create table []");
                }
                catch (SQLiteException)
                {
                }

                SQLiteLogEventHandler handler = (s, e) =>
                {
                    logCount++;
                    lastErrorCode = (SQLiteErrorCode)e.ErrorCode;
                };
                SQLiteLog.Log += handler;

                try
                {
                    conn.Execute(@"create table []");
                }
                catch (SQLiteException)
                {
                }

                Assert.AreEqual(1, logCount);
                Assert.AreEqual(SQLiteErrorCode.Error, lastErrorCode);

                SQLiteLog.Log -= handler;
                lastErrorCode  = SQLiteErrorCode.Ok;

                try
                {
                    conn.Execute(@"create table []");
                }
                catch (SQLiteException)
                {
                }

                Assert.AreEqual(1, logCount);
                Assert.AreEqual(SQLiteErrorCode.Ok, lastErrorCode);
            }
        }
Exemple #3
0
        ///////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Creates and initializes the default log event handler.
        /// </summary>
        private static void InitializeDefaultHandler()
        {
            lock (syncRoot)
            {
                if (_defaultHandler == null)
                    _defaultHandler = new SQLiteLogEventHandler(LogEventHandler);
            }
        }