Skip to content

Commit ca36eac

Browse files
author
Jeff Treuting
committed
Building out CachingStrategies sections
1 parent 29af29d commit ca36eac

12 files changed

Lines changed: 94 additions & 63 deletions

SharpRepository.Repository/Configuration/ConfigurationHelper.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ public static void CheckForInterface(Type type, Type interfaceType)
1414

1515
public static IRepository<T, TKey> GetDefaultInstance<T, TKey>(RepositoriesSectionGroup repositoriesSection) where T : class, new()
1616
{
17+
// I thought repositoriesSection.Sections was just ones that the user added to their configuration but it is all that are defined at the top section and sectionGroups part
18+
1719
// see if there is a default repository section
1820
var defaultSection = repositoriesSection.Sections["default"];
1921

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System;
2+
3+
namespace SharpRepository.Repository.Configuration
4+
{
5+
public interface ICachingStrategyElement
6+
{
7+
string Name { get; set; }
8+
string CachingProvider { get; set; }
9+
}
10+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace SharpRepository.Repository.Configuration
2+
{
3+
public interface IRepositoryElement
4+
{
5+
string Name { get; set; }
6+
7+
IRepository<T, TKey> GetInstance<T, TKey>() where T : class, new();
8+
}
9+
}

SharpRepository.Repository/Configuration/RepositoriesSection.cs renamed to SharpRepository.Repository/Configuration/RepositoriesSectionGroup.cs

File renamed without changes.

SharpRepository.Repository/Configuration/RepositoryElement.cs

Lines changed: 0 additions & 36 deletions
This file was deleted.

SharpRepository.Repository/Configuration/RepositoryElementCollection.cs

Lines changed: 0 additions & 24 deletions
This file was deleted.

SharpRepository.Repository/Configuration/SharpRepositoryConfiguration.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@ namespace SharpRepository.Repository.Configuration
55
{
66
public interface ISharpRepositoryConfiguration
77
{
8+
// TODO: this should be changed to something that pople can build up themselves, then have a translation in the SectionGroup implementation to go from RepositoriesSectioNGroup to that property
89
RepositoriesSectionGroup Repositories { get; }
10+
911
IRepository<T, TKey> GetInstance<T, TKey>() where T : class, new();
1012
}
1113

1214
public class SharpRepositoryConfiguration : ISharpRepositoryConfiguration
1315
{
1416
public RepositoriesSectionGroup Repositories { get; set; }
17+
1518
public IRepository<T, TKey> GetInstance<T, TKey>() where T : class, new()
1619
{
1720
return ConfigurationHelper.GetDefaultInstance<T, TKey>(Repositories);

SharpRepository.Repository/Configuration/SharpRepositorySectionGroup.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ public RepositoriesSectionGroup Repositories
1010
get { return (RepositoriesSectionGroup)base.SectionGroups["repositories"]; }
1111
}
1212

13+
[ConfigurationProperty("cachingStrategies")]
14+
public ConfigurationSectionGroup CachingStrategies
15+
{
16+
get { return SectionGroups["cachingStrategies"]; }
17+
}
18+
1319
public IRepository<T, TKey> GetInstance<T, TKey>() where T : class, new()
1420
{
1521
return ConfigurationHelper.GetDefaultInstance<T, TKey>(Repositories);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System.Configuration;
2+
3+
namespace SharpRepository.Repository.Configuration
4+
{
5+
public class StandardCachingStrategySection : ConfigurationSection, ICachingStrategyElement
6+
{
7+
[ConfigurationProperty("name", IsRequired = true)]
8+
public string Name
9+
{
10+
get { return (string)base["name"]; }
11+
set { base["name"] = value; }
12+
}
13+
14+
[ConfigurationProperty("cachingProvider")]
15+
public string CachingProvider
16+
{
17+
get { return (string)base["cachingProvider"]; }
18+
set { base["cachingProvider"] = value; }
19+
}
20+
}
21+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System;
2+
using System.Configuration;
3+
4+
namespace SharpRepository.Repository.Configuration
5+
{
6+
public class TimeoutCachingStrategySection : ConfigurationSection, ICachingStrategyElement
7+
{
8+
[ConfigurationProperty("name", IsRequired = true)]
9+
public string Name
10+
{
11+
get { return (string)base["name"]; }
12+
set { base["name"] = value; }
13+
}
14+
15+
// TODO: add validator
16+
[ConfigurationProperty("timeout", IsRequired = true)]
17+
public int Timeout
18+
{
19+
get { return (int)base["timeout"]; }
20+
set { base["timeout"] = value; }
21+
}
22+
23+
[ConfigurationProperty("cachingProvider")]
24+
public string CachingProvider
25+
{
26+
get { return (string)base["cachingProvider"]; }
27+
set { base["cachingProvider"] = value; }
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)