Now let's add in the constructor as follows:
public SQLiteStorage(ISQLiteSetup sqliteSetup, ILogger log) { _dbPath = sqliteSetup?.DatabasePath; _sqlitePlatform = sqliteSetup?.Platform; _log = log; _tag = $"{GetType()} "; }
Here we can see some C# 6.0 syntax. Using the question mark (?
) after the constructor parameter sqliteSetup
means that, if the object is not null, we can access the property. This avoids having to create an if
statement such as the following:
If (sqliteSetup != null) _dbPath = sqliteSetup?.DatabasePath;
There is also some more C# 6.0 syntax with the following:
_tag = $"{GetType()} ";
The dollar sign ($
) character is used for interpolated strings. Interpolated string expressions create a string by replacing the contained expressions with the ToString
representations of the expressions' results.
Look more closely at the items we are assigning. We are using the SQLiteSetup
object to set the database path and SQLite...