Skip to content

Commit

Permalink
EncryptedTable and TableSearch enhancements
Browse files Browse the repository at this point in the history
New constructor for EncryptedTable that allows CryptEngine to be
"inherited" from database connection; new ability to set case
sensitivity and trimming on all TableSearch match items by "forced"
properties.
  • Loading branch information
ellisnet committed Oct 11, 2014
1 parent bb9df55 commit 76f7de4
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 2 deletions.
11 changes: 11 additions & 0 deletions Portable.Data.Sqlite/EncryptedTable/EncryptedTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,17 @@ public EncryptedTable(IObjectCryptEngine cryptEngine, SqliteAdoConnection dbConn
}
}

/// <summary>
/// Creates an instance of the encrypted table object based on the specified values, using the CryptEngine associated with the database connection
/// </summary>
/// <param name="dbConnection">The SQLite database connection to be used when interacting with the table</param>
/// <param name="checkDbTable">Check to make sure the associated SQLite table exists, and create if necessary</param>
/// <param name="tableName">Specify a desired name of the SQLite table, instead of using a name derived from the object type</param>
public EncryptedTable(SqliteAdoConnection dbConnection, bool checkDbTable = true, string tableName = null)
: this(((dbConnection == null) ? null : dbConnection._cryptEngine),
dbConnection, checkDbTable, tableName) {
}

#endregion

/// <summary>
Expand Down
52 changes: 50 additions & 2 deletions Portable.Data.Sqlite/EncryptedTable/TableSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,60 @@ public class TableSearch {
List<TableSearchItem> _matchItems = new List<TableSearchItem>();
TableSearchType _searchType = TableSearchType.MatchAll;

SearchItemCaseSensitivity _forcedItemCaseSensitivity = SearchItemCaseSensitivity.CaseInsensitive;
bool _caseSensitivityForced = false;
SearchItemTrimming _forcedItemTrimming = SearchItemTrimming.AutoTrim;
bool _trimmingForced = false;

/// <summary>
/// Set the (forced) Case Sensitivity of all table search match items
/// </summary>
public SearchItemCaseSensitivity ForcedItemCaseSensitivity {
set { _forcedItemCaseSensitivity = value; _caseSensitivityForced = true; }
}

/// <summary>
/// Set the (forced) Trimming of all table search match items
/// </summary>
public SearchItemTrimming ForcedItemTrimming {
set { _forcedItemTrimming = value; _trimmingForced = true; }
}

/// <summary>
/// List of properties and values to be used in identifying matching objects - IMPORTANT: If this list contains no members, all compared objects will match
/// </summary>
public List<TableSearchItem> MatchItems {
get { return _matchItems; }
set { _matchItems = value ?? new List<TableSearchItem>(); }
get {
if (_caseSensitivityForced) {
foreach (var item in _matchItems) {
item.CaseSensitivity = _forcedItemCaseSensitivity;
}
}
if (_trimmingForced) {
foreach (var item in _matchItems) {
item.Trimming = _forcedItemTrimming;
}
}
return _matchItems;
}
set {
if (value == null) {
_matchItems = new List<TableSearchItem>();
}
else {
_matchItems = value;
if (_caseSensitivityForced) {
foreach (var item in _matchItems) {
item.CaseSensitivity = _forcedItemCaseSensitivity;
}
}
if (_trimmingForced) {
foreach (var item in _matchItems) {
item.Trimming = _forcedItemTrimming;
}
}
}
}
}

/// <summary>
Expand Down

0 comments on commit 76f7de4

Please sign in to comment.