Skip to content

Commit 0c6e7c3

Browse files
author
Cristian Vasile
committed
Add a constructor that accepts configuration object
1 parent 25e0fc5 commit 0c6e7c3

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

SharpRepository.Repository/ConfigurationBasedRepository.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using SharpRepository.Repository.Queries;
88
using SharpRepository.Repository.Specifications;
99
using SharpRepository.Repository.Transactions;
10+
using SharpRepository.Repository.Configuration;
1011

1112
namespace SharpRepository.Repository
1213
{
@@ -19,8 +20,9 @@ namespace SharpRepository.Repository
1920
{
2021
protected readonly IRepository<T, TKey> Repository;
2122

22-
// we have 2 constructors so you can use the defualt sharpRepository section or specify a config section
23-
// you can also provide the repository name from the config file instead of whatever the default is if needed
23+
// we have 3 constructors so you can use the defualt sharpRepository section or specify a config section
24+
// you can provide the repository name from the config file instead of whatever the default is if needed
25+
// you can also provide the configuration object instead of building one from the config file
2426
public ConfigurationBasedRepository(string configSection, string repositoryName)
2527
{
2628
Repository = RepositoryFactory.GetInstance<T, TKey>(configSection, repositoryName);
@@ -32,6 +34,11 @@ public ConfigurationBasedRepository(string repositoryName = null)
3234
Repository = RepositoryFactory.GetInstance<T, TKey>(repositoryName);
3335
}
3436

37+
public ConfigurationBasedRepository(ISharpRepositoryConfiguration configuration, string repositoryName = null)
38+
{
39+
Repository = RepositoryFactory.GetInstance<T, TKey>(configuration, repositoryName);
40+
}
41+
3542
public void Dispose()
3643
{
3744
Repository.Dispose();

0 commit comments

Comments
 (0)