3
3
4
4
namespace NHibernate . Cfg . Loquacious
5
5
{
6
- internal class CacheConfigurationProperties : ICacheConfigurationProperties
6
+ public class CacheConfigurationProperties
7
+ #pragma warning disable 618
8
+ : ICacheConfigurationProperties
9
+ #pragma warning restore 618
7
10
{
8
11
private readonly Configuration cfg ;
9
12
@@ -46,6 +49,8 @@ public void QueryCache<TFactory>() where TFactory : IQueryCache
46
49
throw new InvalidOperationException ( "This method is invalid and should not be used. Use QueryCacheFactory method instead." ) ;
47
50
}
48
51
52
+ #endregion
53
+
49
54
public void QueryCacheFactory < TFactory > ( ) where TFactory : IQueryCacheFactory
50
55
{
51
56
UseSecondLevelCache = true ;
@@ -57,10 +62,12 @@ private bool UseSecondLevelCache
57
62
{
58
63
set { cfg . SetProperty ( Environment . UseSecondLevelCache , value . ToString ( ) . ToLowerInvariant ( ) ) ; }
59
64
}
60
- #endregion
61
65
}
62
66
63
- internal class CacheConfiguration : ICacheConfiguration
67
+ public class CacheConfiguration
68
+ #pragma warning disable 618
69
+ : ICacheConfiguration
70
+ #pragma warning restore 618
64
71
{
65
72
private readonly FluentSessionFactoryConfiguration fc ;
66
73
@@ -75,39 +82,66 @@ internal Configuration Configuration
75
82
get { return fc . Configuration ; }
76
83
}
77
84
78
- #region Implementation of ICacheConfiguration
79
-
80
- public ICacheConfiguration Through < TProvider > ( ) where TProvider : ICacheProvider
85
+ public CacheConfiguration Through < TProvider > ( ) where TProvider : ICacheProvider
81
86
{
82
87
fc . Configuration . SetProperty ( Environment . UseSecondLevelCache , "true" ) ;
83
88
fc . Configuration . SetProperty ( Environment . CacheProvider , typeof ( TProvider ) . AssemblyQualifiedName ) ;
84
89
return this ;
85
90
}
86
91
87
- public ICacheConfiguration PrefixingRegionsWith ( string regionPrefix )
92
+ public CacheConfiguration PrefixingRegionsWith ( string regionPrefix )
88
93
{
89
94
fc . Configuration . SetProperty ( Environment . CacheRegionPrefix , regionPrefix ) ;
90
95
return this ;
91
96
}
92
97
93
- public ICacheConfiguration UsingMinimalPuts ( )
98
+ public CacheConfiguration UsingMinimalPuts ( )
94
99
{
95
100
fc . Configuration . SetProperty ( Environment . UseMinimalPuts , true . ToString ( ) . ToLowerInvariant ( ) ) ;
96
101
return this ;
97
102
}
98
103
99
- public IFluentSessionFactoryConfiguration WithDefaultExpiration ( int seconds )
104
+ public FluentSessionFactoryConfiguration WithDefaultExpiration ( int seconds )
100
105
{
101
106
fc . Configuration . SetProperty ( Environment . CacheDefaultExpiration , seconds . ToString ( ) ) ;
102
107
return fc ;
103
108
}
104
109
105
- public IQueryCacheConfiguration Queries { get ; private set ; }
110
+ public QueryCacheConfiguration Queries { get ; }
111
+
112
+ #pragma warning disable 618
113
+ #region Implementation of ICacheConfiguration
114
+
115
+ ICacheConfiguration ICacheConfiguration . Through < TProvider > ( )
116
+ {
117
+ return Through < TProvider > ( ) ;
118
+ }
119
+
120
+ ICacheConfiguration ICacheConfiguration . PrefixingRegionsWith ( string regionPrefix )
121
+ {
122
+ return PrefixingRegionsWith ( regionPrefix ) ;
123
+ }
124
+
125
+ ICacheConfiguration ICacheConfiguration . UsingMinimalPuts ( )
126
+ {
127
+ return UsingMinimalPuts ( ) ;
128
+ }
129
+
130
+ IFluentSessionFactoryConfiguration ICacheConfiguration . WithDefaultExpiration ( int seconds )
131
+ {
132
+ return WithDefaultExpiration ( seconds ) ;
133
+ }
134
+
135
+ IQueryCacheConfiguration ICacheConfiguration . Queries => Queries ;
106
136
107
137
#endregion
138
+ #pragma warning restore 618
108
139
}
109
140
110
- internal class QueryCacheConfiguration : IQueryCacheConfiguration
141
+ public class QueryCacheConfiguration
142
+ #pragma warning disable 618
143
+ : IQueryCacheConfiguration
144
+ #pragma warning restore 618
111
145
{
112
146
private readonly CacheConfiguration cc ;
113
147
@@ -116,10 +150,8 @@ public QueryCacheConfiguration(CacheConfiguration cc)
116
150
this . cc = cc ;
117
151
}
118
152
119
- #region Implementation of IQueryCacheConfiguration
120
-
121
153
// 6.0 TODO: enable constraint and remove runtime type check
122
- public ICacheConfiguration Through < TFactory > ( ) // where TFactory : IQueryCacheFactory
154
+ public CacheConfiguration Through < TFactory > ( ) //where TFactory : IQueryCacheFactory
123
155
{
124
156
if ( ! typeof ( IQueryCacheFactory ) . IsAssignableFrom ( typeof ( TFactory ) ) )
125
157
throw new ArgumentException ( $ "{ nameof ( TFactory ) } must be an { nameof ( IQueryCacheFactory ) } ", nameof ( TFactory ) ) ;
@@ -130,6 +162,15 @@ public ICacheConfiguration Through<TFactory>() // where TFactory : IQueryCacheFa
130
162
return cc ;
131
163
}
132
164
165
+ #region Implementation of IQueryCacheConfiguration
166
+ #pragma warning disable 618
167
+
168
+ ICacheConfiguration IQueryCacheConfiguration . Through < TFactory > ( )
169
+ {
170
+ return Through < TFactory > ( ) ;
171
+ }
172
+
173
+ #pragma warning restore 618
133
174
#endregion
134
175
}
135
176
}
0 commit comments