@@ -28,6 +28,10 @@ public bool ContainsPrefix(string prefix)
28
28
29
29
public ValueProviderResult GetValue ( string key )
30
30
{
31
+ int pos = key . LastIndexOf ( "." , StringComparison . Ordinal ) ;
32
+ if ( pos != - 1 )
33
+ key = key . Substring ( pos + 1 ) ;
34
+
31
35
string [ ] value = null ;
32
36
33
37
if ( _context . CookieData . Values ? . TryGetValue ( key , out value ) != true )
@@ -44,44 +48,42 @@ public ValueProviderResult GetValue(string key)
44
48
45
49
public class GriddlyCookieFilterValueProviderFactory : ValueProviderFactory
46
50
{
47
- Func < ControllerContext , bool > _canProvide = null ;
51
+ Func < ControllerContext , bool > _canProvide = ( controllerContext ) => controllerContext . HttpContext . Request . QueryString . Count == 0 ;
48
52
49
53
public GriddlyCookieFilterValueProviderFactory ( Func < ControllerContext , bool > canProvide = null )
50
54
{
51
- _canProvide = canProvide ;
55
+ if ( canProvide != null )
56
+ _canProvide = canProvide ;
52
57
}
53
58
54
59
public override IValueProvider GetValueProvider ( ControllerContext controllerContext )
55
60
{
56
- if ( controllerContext . IsChildAction && controllerContext . HttpContext . Request . QueryString . Count == 0 )
61
+ if ( controllerContext . IsChildAction && _canProvide . Invoke ( controllerContext ) )
57
62
{
58
- if ( _canProvide ? . Invoke ( controllerContext ) != false )
59
- {
60
- var context = controllerContext . Controller . GetOrCreateGriddlyContext ( ) ;
61
- var cookie = controllerContext . HttpContext . Request . Cookies [ context . CookieName ] ;
63
+ var context = controllerContext . Controller . GetOrCreateGriddlyContext ( ) ;
64
+ var cookie = controllerContext . HttpContext . Request . Cookies [ context . CookieName ] ;
62
65
63
- if ( cookie != null && ! string . IsNullOrWhiteSpace ( cookie . Value ) )
66
+ if ( cookie != null && ! string . IsNullOrWhiteSpace ( cookie . Value ) )
67
+ {
68
+ try
64
69
{
65
- try
66
- {
67
- var data = JsonConvert . DeserializeObject < GriddlyFilterCookieData > ( cookie . Value ) ;
68
-
69
- // chrome/ff don't delete session cookies if they're set to "continue where you left off"
70
- // https://stackoverflow.com/questions/10617954/chrome-doesnt-delete-session-cookies
71
- // only use a cookie if it's new within 100 minutes
72
- if ( data . CreatedUtc != null && ( DateTime . UtcNow - data . CreatedUtc . Value ) . TotalMinutes < 100 )
73
- {
74
- context . CookieData = data ;
75
- context . IsDefaultSkipped = true ;
76
-
77
- return new GriddlyCookieFilterValueProvider ( context ) ;
78
- }
79
- }
80
- catch
70
+ var data = JsonConvert . DeserializeObject < GriddlyFilterCookieData > ( cookie . Value ) ;
71
+
72
+ // chrome/ff don't delete session cookies if they're set to "continue where you left off"
73
+ // https://stackoverflow.com/questions/10617954/chrome-doesnt-delete-session-cookies
74
+ // only use a cookie if it's new within 100 minutes
75
+ if ( data . CreatedUtc != null && ( DateTime . UtcNow - data . CreatedUtc . Value ) . TotalMinutes < 100 )
81
76
{
82
- // TODO: log it?
77
+ context . CookieData = data ;
78
+ context . IsDefaultSkipped = true ;
79
+
80
+ return new GriddlyCookieFilterValueProvider ( context ) ;
83
81
}
84
82
}
83
+ catch
84
+ {
85
+ // TODO: log it?
86
+ }
85
87
}
86
88
}
87
89
0 commit comments