/// <summary> /// Disposes of the command and clears all member variables /// </summary> public override void Dispose() { // If a reader is active on this command, don't destroy the command, instead let the reader do it SqliteDataReader reader = null; if (_activeReader != null) { try { reader = _activeReader.Target as SqliteDataReader; } catch { } } if (reader != null) { reader._disposeCommand = true; _activeReader = null; return; } _cryptEngine = null; Connection = null; _parameterCollection.Clear(); _commandText = null; }
/// <summary> /// Initializes a command with the given SQL, connection and transaction /// </summary> /// <param name="commandText">The SQL command text</param> /// <param name="connection">The connection to associate with the command</param> /// <param name="transaction">The transaction the command should be associated with</param> /// <param name="cryptEngine">The cryptography 'engine' to use for encryption/decryption operations</param> public SqliteCommand(string commandText, SqliteAdoConnection connection, SqliteTransaction transaction, IObjectCryptEngine cryptEngine = null) { _statementList = null; _activeReader = null; _commandTimeout = 30; _parameterCollection = new SqliteParameterCollection(this); _designTimeVisible = true; _updateRowSource = UpdateRowSource.None; _transaction = null; _cryptEngine = cryptEngine; if (commandText != null) { CommandText = commandText; } if (connection != null) { DbConnection = connection; _commandTimeout = connection.DefaultTimeout; if (_cryptEngine == null) { _cryptEngine = connection._cryptEngine; } } if (transaction != null) { Transaction = transaction; } }
/// <summary> /// Encrypts the Searchable index of the object to a string, using the specified cryptography 'engine' /// </summary> /// <param name="cryptEngine">The cryptography 'engine' to be used for encryption</param> /// <returns>Encrypted string</returns> public string EncryptSearchable(IObjectCryptEngine cryptEngine) { if (cryptEngine == null) { throw new ArgumentNullException("cryptEngine"); } return(EncryptedTableItem.EncryptObjectSearchIndex(this, cryptEngine)); }
// ReSharper restore RedundantArgumentDefaultValue /// <summary> Constructor. </summary> /// <param name="commandText"> The command text. </param> /// <param name="connection"> The connection. </param> /// <param name="transaction"> The transaction. </param> /// <param name="cryptEngine"> (Optional) The crypt engine. </param> /// <param name="forMaintenance"> (Optional) True to for maintenance. </param> public SqliteCommand(string commandText, SqliteConnection connection, IDbTransaction transaction, IObjectCryptEngine cryptEngine = null, bool forMaintenance = false) { _commandText = String.IsNullOrWhiteSpace(commandText) ? null : commandText.Trim(); _dbConnection = connection; _forMaintenance = forMaintenance; _database = connection?.Database; _cryptEngine = cryptEngine ?? connection?._cryptEngine; Transaction = transaction; m_parameterCollection = new SqliteParameterCollection(); }
/// <summary> /// Encrypts the specified object to a string /// </summary> /// <param name="objectToEncrypt">The object to be encrypted</param> /// <param name="cryptEngine">The cryptography 'engine' to be used for encryption</param> /// <returns>Encrypted string</returns> public static string EncryptObject(IEncryptedTableItem objectToEncrypt, IObjectCryptEngine cryptEngine) { if (objectToEncrypt == null) { throw new ArgumentNullException("objectToEncrypt"); } if (cryptEngine == null) { throw new ArgumentNullException("cryptEngine"); } return(cryptEngine.EncryptObject(objectToEncrypt)); }
/// <summary> /// Disposes the object and frees up resources /// </summary> public void Dispose() { _cryptEngine = null; }
/// <summary> Constructor. </summary> /// <param name="commandText"> The command text. </param> /// <param name="connection"> The connection. </param> /// <param name="cryptEngine"> The crypt engine. </param> /// <param name="forMaintenance"> (Optional) True to for maintenance. </param> public SqliteCommand(string commandText, SqliteConnection connection, IObjectCryptEngine cryptEngine, bool forMaintenance = false) : this(commandText, connection, null, cryptEngine, forMaintenance) { }
/// <summary> Constructor. </summary> /// <param name="commandText"> The command text. </param> /// <param name="cryptEngine"> (Optional) The crypt engine. </param> public SqliteCommand(string commandText, IObjectCryptEngine cryptEngine = null) : this(commandText, null, null, cryptEngine, false) { }
/// <summary> Constructor. </summary> /// <param name="cryptEngine"> The crypt engine. </param> public SqliteCommand(IObjectCryptEngine cryptEngine) : this(null, null, null, cryptEngine, false) { }
/// <summary> /// Disposes of the SqliteAdoConnection, closing it if it is active. /// </summary> public override void Dispose() { if (_sql != null) _sql.Dispose(); _sql = null; _cryptEngine = null; _sqliteDbConnection = null; base.Dispose(); Close(); }
/////<overloads> ///// Constructs a new SqliteAdoConnection object ///// </overloads> ///// <summary> ///// Default constructor ///// </summary> //public SqliteAdoConnection() // : this("") { //} ///// <summary> ///// Initializes the connection with the specified connection string ///// </summary> ///// <param name="connectionString">The connection string to use on the connection</param> //public SqliteAdoConnection(string connectionString) { // _sql = null; // _connectionState = ConnectionState.Closed; // _connectionString = ""; // _transactionLevel = 0; // _version = 0; // //_commandList = new List<WeakReference>(); // if (connectionString != null) // ConnectionString = connectionString; //} #endregion /// <summary> /// Initializes the connection with the specified SQLite connection /// </summary> /// <param name="connection">The SQLite connection to be wrap as an ADO connection</param> /// <param name="cryptEngine">The cryptographic engine to be used for encryption operations</param> public SqliteAdoConnection(SQLitePCL.ISQLiteConnection connection, IObjectCryptEngine cryptEngine) { if (connection == null) throw new ArgumentNullException("connection"); _sqliteDbConnection = connection; _cryptEngine = cryptEngine; _sql = null; _connectionState = ConnectionState.Closed; _connectionString = ""; _transactionLevel = 0; _version = 0; //_commandList = new List<WeakReference>(); }