@@ -8,74 +8,86 @@ namespace Microsoft.AspNet.Http.Features
8
8
internal sealed class FeatureHelpers
9
9
{
10
10
public static T GetAndCache < T > (
11
- IFeatureCache cache ,
12
- IFeatureCollection features ,
13
- ref T cachedObject )
11
+ IFeatureCache cache ,
12
+ IFeatureCollection features ,
13
+ ref T cachedObject )
14
14
{
15
15
cache . CheckFeaturesRevision ( ) ;
16
- if ( cachedObject == null )
16
+
17
+ T obj = cachedObject ;
18
+ if ( obj == null )
17
19
{
18
- cachedObject = features . Get < T > ( ) ;
20
+ obj = features . Get < T > ( ) ;
21
+ cachedObject = obj ;
19
22
}
20
- return cachedObject ;
23
+ return obj ;
21
24
}
22
25
23
26
public static T GetOrCreateAndCache < T > (
24
- IFeatureCache cache ,
25
- IFeatureCollection features ,
26
- Func < T > factory ,
27
- ref T cachedObject )
27
+ IFeatureCache cache ,
28
+ IFeatureCollection features ,
29
+ Func < T > factory ,
30
+ ref T cachedObject )
28
31
{
29
32
cache . CheckFeaturesRevision ( ) ;
30
- if ( cachedObject == null )
33
+
34
+ T obj = cachedObject ;
35
+ if ( obj == null )
31
36
{
32
- cachedObject = features . Get < T > ( ) ;
33
- if ( cachedObject == null )
37
+ obj = features . Get < T > ( ) ;
38
+ if ( obj == null )
34
39
{
35
- cachedObject = factory ( ) ;
36
- features . Set ( cachedObject ) ;
40
+ obj = factory ( ) ;
41
+ cachedObject = obj ;
42
+ features . Set ( obj ) ;
37
43
}
38
44
}
39
- return cachedObject ;
45
+ return obj ;
40
46
}
41
47
42
48
public static T GetOrCreateAndCache < T > (
43
- IFeatureCache cache ,
44
- IFeatureCollection features ,
45
- Func < IFeatureCollection , T > factory ,
46
- ref T cachedObject )
49
+ IFeatureCache cache ,
50
+ IFeatureCollection features ,
51
+ Func < IFeatureCollection , T > factory ,
52
+ ref T cachedObject )
47
53
{
48
54
cache . CheckFeaturesRevision ( ) ;
49
- if ( cachedObject == null )
55
+
56
+ T obj = cachedObject ;
57
+ if ( obj == null )
50
58
{
51
- cachedObject = features . Get < T > ( ) ;
52
- if ( cachedObject == null )
59
+ obj = features . Get < T > ( ) ;
60
+ if ( obj == null )
53
61
{
54
- cachedObject = factory ( features ) ;
55
- features . Set ( cachedObject ) ;
62
+ obj = factory ( features ) ;
63
+ cachedObject = obj ;
64
+ features . Set ( obj ) ;
56
65
}
57
66
}
58
- return cachedObject ;
67
+ return obj ;
59
68
}
60
69
61
70
public static T GetOrCreateAndCache < T > (
62
- IFeatureCache cache ,
63
- IFeatureCollection features ,
64
- HttpRequest request ,
65
- Func < HttpRequest , T > factory ,
66
- ref T cachedObject )
71
+ IFeatureCache cache ,
72
+ IFeatureCollection features ,
73
+ HttpRequest request ,
74
+ Func < HttpRequest , T > factory ,
75
+ ref T cachedObject )
67
76
{
68
77
cache . CheckFeaturesRevision ( ) ;
69
- if ( cachedObject == null )
78
+
79
+ T obj = cachedObject ;
80
+ if ( obj == null )
70
81
{
71
- cachedObject = features . Get < T > ( ) ;
72
- if ( cachedObject == null )
82
+ obj = features . Get < T > ( ) ;
83
+ if ( obj == null )
73
84
{
74
- cachedObject = factory ( request ) ;
75
- features . Set ( cachedObject ) ;
85
+ obj = factory ( request ) ;
86
+ cachedObject = obj ;
87
+ features . Set ( obj ) ;
76
88
}
77
89
}
78
- return cachedObject ;
90
+ return obj ;
79
91
}
80
92
}
81
93
}
0 commit comments