-
Notifications
You must be signed in to change notification settings - Fork 49
/
OutputCache.cs
59 lines (52 loc) · 1.7 KB
/
OutputCache.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using System.Configuration;
using System.Web.Caching;
namespace DevTrends.MvcDonutCaching
{
public sealed class OutputCache
{
static OutputCache()
{
DefaultOptions = OutputCacheOptions.None;
var providerSettings = new CacheSettingsManager().RetrieveOutputCacheProviderSettings();
if (providerSettings == null || providerSettings.Type == null)
{
Instance = new MemoryCacheProvider();
}
else
{
try
{
Instance = (OutputCacheProvider)Activator.CreateInstance(Type.GetType(providerSettings.Type));
Instance.Initialize(providerSettings.Name, providerSettings.Parameters);
}
catch (Exception ex)
{
throw new ConfigurationErrorsException(
string.Format("Unable to instantiate and initialize OutputCacheProvider of type '{0}'. Make sure you are specifying the full type name.", providerSettings.Type),
ex
);
}
}
}
private OutputCache()
{
}
/// <summary>
/// Gets the current <see cref="OutputCacheManager"/> instance.
/// </summary>
public static OutputCacheProvider Instance
{
get;
private set;
}
/// <summary>
/// Specifies the default value for the <see cref="DonutOutputCacheAttribute.Options"/>
/// </summary>
public static OutputCacheOptions DefaultOptions
{
get;
set;
}
}
}