public SQLExtConnectionRegister(string dbfile, bool utctimeindicator, AccessMode mode = AccessMode.ReaderWriter) : base(mode)
        {
            try
            {
                DBFile     = dbfile;
                connection = DbFactory.CreateConnection();

                // Use the database selected by maindb as the 'main' database
                connection.ConnectionString = "Data Source=" + DBFile.Replace("\\", "\\\\") + ";Pooling=true;";

                if (utctimeindicator)   // indicate treat dates as UTC.
                {
                    connection.ConnectionString += "DateTimeKind=Utc;";
                }

                if (mode == AccessMode.Reader)
                {
                    connection.ConnectionString += "Read Only=True;";
                }

                // System.Diagnostics.Debug.WriteLine("Created connection " + connection.ConnectionString);

                connection.Open();

                registerclass = new SQLExtRegister(this);
            }
            catch
            {
                throw;
            }
        }
        static public DateTime GetSettingDate(string key, DateTime defaultvalue, TConn conn = null)
        {
            string s = RegisterGet(key, "--", cn => { var reg = new SQLExtRegister(cn); return(reg.GetSettingString(key, "--")); }, conn);

            if (!DateTime.TryParse(s, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AssumeUniversal | System.Globalization.DateTimeStyles.AdjustToUniversal, out DateTime date))
            {
                date = defaultvalue;
            }

            return(date);
        }
        // provided for DB upgrade operations at the basic level..

        public void PerformUpgrade(int newVersion, bool catchErrors, bool backupDbFile, string[] queries, Action doAfterQueries = null)
        {
            if (backupDbFile)
            {
                string dbfile = DBFile;

                try
                {
                    File.Copy(dbfile, dbfile.Replace(".sqlite", $"{newVersion - 1}.sqlite"));
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Trace.WriteLine("Exception: " + ex.Message);
                    System.Diagnostics.Trace.WriteLine("Trace: " + ex.StackTrace);
                }
            }

            try
            {
                ExecuteNonQueries(queries);
            }
            catch (Exception ex)
            {
                if (!catchErrors)
                {
                    throw;
                }

                System.Diagnostics.Trace.WriteLine("Exception: " + ex.Message);
                System.Diagnostics.Trace.WriteLine("Trace: " + ex.StackTrace);
                System.Windows.Forms.MessageBox.Show($"UpgradeDB{newVersion} error: " + ex.Message);
            }

            doAfterQueries?.Invoke();

            SQLExtRegister reg = new SQLExtRegister(this);

            reg.PutSettingInt("DBVer", newVersion);
        }
 static public bool PutSettingDate(string key, DateTime value, TConn conn = null)        // public IF
 {
     return(RegisterPut(cn => { var reg = new SQLExtRegister(cn); return reg.PutSettingString(key, value.ToStringZulu()); }, conn));
 }
 static public bool PutSettingString(string key, string strvalue, TConn conn = null)        // public IF
 {
     return(RegisterPut(cn => { var reg = new SQLExtRegister(cn); return reg.PutSettingString(key, strvalue); }, conn));
 }
 static public bool PutSettingBool(string key, bool boolvalue, TConn conn = null)
 {
     return(RegisterPut(cn => { var reg = new SQLExtRegister(cn); return reg.PutSettingBool(key, boolvalue); }, conn));
 }
 static public string GetSettingString(string key, string defaultvalue, TConn conn = null)
 {
     return(RegisterGet(key, defaultvalue, cn => { var reg = new SQLExtRegister(cn); return reg.GetSettingString(key, defaultvalue); }, conn));
 }
 static public bool GetSettingBool(string key, bool defaultvalue, TConn conn = null)
 {
     return(RegisterGet(key, defaultvalue, cn => { var reg = new SQLExtRegister(cn); return reg.GetSettingBool(key, defaultvalue); }, conn));
 }
 static public double GetSettingDouble(string key, double defaultvalue, TConn conn = null)
 {
     return(RegisterGet(key, defaultvalue, cn => { var reg = new SQLExtRegister(cn); return reg.GetSettingDouble(key, defaultvalue); }, conn));
 }
 static public int GetSettingInt(string key, int defaultvalue, TConn conn = null)
 {
     return((int)RegisterGet(key, defaultvalue, cn => { var reg = new SQLExtRegister(cn); return reg.GetSettingInt(key, defaultvalue); }, conn));
 }
 static public bool DeleteKey(string key, TConn conn = null)
 {
     return(RegisterDelete(key, cn => { var reg = new SQLExtRegister(cn); return reg.DeleteKey(key); }, conn));
 }
 static public bool keyExists(string sKey, TConn conn = null)
 {
     return(RegisterGet(sKey, false, cn => { var reg = new SQLExtRegister(cn); return reg.keyExists(sKey); }, conn));
 }