Skip to content

FileDapperMaticDatasourceRepository ​

Namespace: MJCZone.DapperMatic.AspNetCore.Repositories

Assembly: MJCZone.DapperMatic.AspNetCore

Summary ​

File-based implementation of IDapperMaticDatasourceRepository that stores datasources in a JSON file with encrypted connection strings: <c>{ "datasources": [ ... ] }</c>, written whole on each change.

Inheritance ​

Base Class: DapperMaticDatasourceRepositoryBase

Implemented Interfaces:

  • IDisposable

sealed public

Contents ​

Constructors (1) | Methods (15)

Constructors ​

FileDapperMaticDatasourceRepository ​

Initializes a new instance of the FileDapperMaticDatasourceRepository class.

csharp
FileDapperMaticDatasourceRepository(
    string filePath,
    IDatasourceIdFactory datasourceIdFactory,
    DapperMaticOptions} options,
    FileDapperMaticDatasourceRepository} logger)

Parameters ​

  • filePath (string) - The path to the JSON file where datasources will be stored.
  • datasourceIdFactory (IDatasourceIdFactory) - The factory to generate datasource IDs.
  • options (DapperMaticOptions}) - The DapperMatic options containing the encryption key.
  • logger (FileDapperMaticDatasourceRepository}) - The logger instance.

Methods ​

MethodSummary
Initialize
AddDatasourceAsync
UpdateDatasourceAsync
RemoveDatasourceAsync
GetDatasourcesAsync
GetDatasourceAsync
DatasourceExistsAsync
GetConnectionStringAsync
DisposeReleases all resources used by the current instance of the FileDapperMaticDatasourceRepository cla...
EncryptConnectionStringEncrypts a connection string for secure storage, with the current key, prefixed by that key's id.
DecryptConnectionStringDecrypts an encrypted connection string for internal use, with the key whose id it carries: the curr...
GetType
ToString
Equals
GetHashCode

Initialize ​

csharp
void Initialize()

AddDatasourceAsync ​

csharp
Task&lt;bool&gt; AddDatasourceAsync()

Returns ​

Type: Task&lt;bool&gt;

UpdateDatasourceAsync ​

csharp
Task&lt;bool&gt; UpdateDatasourceAsync()

Returns ​

Type: Task&lt;bool&gt;

RemoveDatasourceAsync ​

csharp
Task&lt;bool&gt; RemoveDatasourceAsync()

Returns ​

Type: Task&lt;bool&gt;

GetDatasourcesAsync ​

csharp
Task&lt;List&lt;DatasourceDto&gt;&gt; GetDatasourcesAsync()

Returns ​

Type: Task<List<DatasourceDto>>

GetDatasourceAsync ​

csharp
Task&lt;DatasourceDto?&gt; GetDatasourceAsync()

Returns ​

Type: Task<DatasourceDto?>

DatasourceExistsAsync ​

csharp
Task&lt;bool&gt; DatasourceExistsAsync()

Returns ​

Type: Task&lt;bool&gt;

GetConnectionStringAsync ​

csharp
Task&lt;string?&gt; GetConnectionStringAsync()

Returns ​

Type: Task&lt;string?&gt;

Dispose ​

Releases all resources used by the current instance of the FileDapperMaticDatasourceRepository class.

csharp
void Dispose()

EncryptConnectionString ​

Encrypts a connection string for secure storage, with the current key, prefixed by that key's id.

csharp
EncryptConnectionString(string connectionString)

Parameters ​

  • connectionString (string) - The plain text connection string.

Returns ​

The encrypted connection string, as .

DecryptConnectionString ​

Decrypts an encrypted connection string for internal use, with the key whose id it carries: the current key or one of the previous ones. One stored without a key id is tried with each.

csharp
DecryptConnectionString(string encryptedConnectionString)

Parameters ​

  • encryptedConnectionString (string) - The encrypted connection string.

Returns ​

The decrypted plain text connection string.

GetType ​

csharp
GetType()

ToString ​

csharp
ToString()

Equals ​

csharp
Equals()

GetHashCode ​

csharp
GetHashCode()