Skip to content

Commit 13226bf

Browse files
committed
Made some work towards DI compatibility.
Little refactorings, the OutputCacheManager(OutputCacheProvider outputCacheProvider, IKeyBuilder keyBuilder) ctor is now public. The DonutOutputCacheAttribute has now two public constructors.
1 parent cc2fea6 commit 13226bf

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

DevTrends.MvcDonutCaching/DonutOutputCacheAttribute.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ public class DonutOutputCacheAttribute : ActionFilterAttribute, IExceptionFilter
1919
private bool? _noStore;
2020
private OutputCacheOptions? _options;
2121

22-
public DonutOutputCacheAttribute()
23-
{
24-
var keyBuilder = new KeyBuilder();
22+
public DonutOutputCacheAttribute() : this(new KeyBuilder()) { }
2523

24+
public DonutOutputCacheAttribute(IKeyBuilder keyBuilder)
25+
{
2626
_keyGenerator = new KeyGenerator(keyBuilder);
2727
_outputCacheManager = new OutputCacheManager(OutputCache.Instance, keyBuilder);
2828
_donutHoleFiller = new DonutHoleFiller(new EncryptingActionSettingsSerialiser(new ActionSettingsSerialiser(), new Encryptor()));

DevTrends.MvcDonutCaching/OutputCacheManager.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@ public class OutputCacheManager : IExtendedOutputCacheManager
1212
private readonly OutputCacheProvider _outputCacheProvider;
1313
private readonly IKeyBuilder _keyBuilder;
1414

15-
public OutputCacheManager()
15+
public OutputCacheManager() : this(OutputCache.Instance, new KeyBuilder())
1616
{
17-
_outputCacheProvider = OutputCache.Instance;
18-
_keyBuilder = new KeyBuilder();
1917
}
2018

21-
internal OutputCacheManager(OutputCacheProvider outputCacheProvider, IKeyBuilder keyBuilder)
19+
public OutputCacheManager(OutputCacheProvider outputCacheProvider, IKeyBuilder keyBuilder)
2220
{
2321
_outputCacheProvider = outputCacheProvider;
2422
_keyBuilder = keyBuilder;

0 commit comments

Comments
 (0)