Skip to content

Commit 45ed61a

Browse files
committed
Merge branch 'master' into net-core-3.1
2 parents 871ef16 + c4d8517 commit 45ed61a

29 files changed

+249
-291
lines changed

.nuget/NuGet.Config

Lines changed: 0 additions & 6 deletions
This file was deleted.

.nuget/NuGet.exe

1.39 MB
Binary file not shown.

.nuget/NuGet.targets

Lines changed: 0 additions & 151 deletions
This file was deleted.

Build/CommonAssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
//
1616
// You can specify all the values or you can default the Revision and Build Numbers
1717
// by using the '*' as shown below:
18-
[assembly: AssemblyVersion("3.2.18")]
19-
[assembly: AssemblyFileVersion("3.2.18")]
18+
[assembly: AssemblyVersion("3.3.3")]
19+
[assembly: AssemblyFileVersion("3.3.3")]
2020
//[assembly: AssemblyInformationalVersion("2.5-filters")]

Build/Griddly.Core.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
<id>Griddly.Core</id>
66
<version></version>
77
<authors>Chris Hynes, Joel Potter</authors>
8-
<!--<licenseUrl></licenseUrl>-->
98
<projectUrl>https://github.com/programcsharp/griddly</projectUrl>
109
<iconUrl>https://raw.githubusercontent.com/programcsharp/griddly/master/Griddly/Content/griddly-32.png</iconUrl>
1110
<requireLicenseAcceptance>false</requireLicenseAcceptance>
11+
<license type="expression">MIT</license>
1212
<description>Pagable sortable MVC enabled grid (core files only)</description>
1313
<!--<summary></summary>-->
1414
<language>en-US</language>

Build/Griddly.nuspec

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@
55
<id>Griddly</id>
66
<version></version>
77
<authors>Chris Hynes, Joel Potter</authors>
8-
<!--<licenseUrl></licenseUrl>-->
98
<projectUrl>http://griddly.com</projectUrl>
109
<iconUrl>https://raw.githubusercontent.com/programcsharp/griddly/master/Griddly/Content/griddly-32.png</iconUrl>
1110
<requireLicenseAcceptance>false</requireLicenseAcceptance>
1211
<!--<license type="expression">MIT</license>-->
1312
<description>Pagable, sortable, MVC enabled grid</description>
14-
<!--<summary></summary>-->
1513
<language>en-US</language>
1614
<dependencies>
1715
<group>

Griddly.Mvc/Griddly.Mvc.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFrameworks>netcoreapp3.1;net45</TargetFrameworks>

Griddly.Mvc/GriddlyColumn.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ public virtual HtmlString RenderValue(object value, bool encode = true)
109109

110110
public class GriddlyColumn<TRow> : GriddlyColumn
111111
{
112+
public GriddlyColumn() : base()
113+
{ }
114+
112115
public GriddlyColumn(LambdaExpression expression, string caption, string columnId) : base(expression, caption, columnId) { }
113116

114117
public Func<TRow, object> Template { get; set; }

Griddly.Mvc/GriddlyCookieFilterValueProvider.cs

Lines changed: 48 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ public bool ContainsPrefix(string prefix)
3333

3434
public ValueProviderResult GetValue(string key)
3535
{
36+
int pos = key.LastIndexOf(".", StringComparison.Ordinal);
37+
if (pos != -1)
38+
key = key.Substring(pos + 1);
39+
3640
string[] value = null;
3741

3842
if (_context.CookieData.Values?.TryGetValue(key, out value) != true)
@@ -54,44 +58,42 @@ public ValueProviderResult GetValue(string key)
5458
#if NET45
5559
public class GriddlyCookieFilterValueProviderFactory : ValueProviderFactory
5660
{
57-
Func<ControllerContext, bool> _canProvide = null;
61+
Func<ControllerContext, bool> _canProvide = (controllerContext) => controllerContext.HttpContext.Request.QueryString.Count == 0;
5862

5963
public GriddlyCookieFilterValueProviderFactory(Func<ControllerContext, bool> canProvide = null)
6064
{
65+
if (canProvide != null)
6166
_canProvide = canProvide;
6267
}
6368

6469
public override IValueProvider GetValueProvider(ControllerContext controllerContext)
6570
{
66-
if (controllerContext.IsChildAction && controllerContext.HttpContext.Request.QueryString.Count == 0)
71+
if (controllerContext.IsChildAction && _canProvide.Invoke(controllerContext))
6772
{
68-
if (_canProvide?.Invoke(controllerContext) != false)
69-
{
70-
var context = controllerContext.Controller.GetOrCreateGriddlyContext();
71-
var cookie = controllerContext.HttpContext.Request.Cookies[context.CookieName];
73+
var context = controllerContext.Controller.GetOrCreateGriddlyContext();
74+
var cookie = controllerContext.HttpContext.Request.Cookies[context.CookieName];
7275

73-
if (cookie != null && !string.IsNullOrWhiteSpace(cookie.Value))
76+
if (cookie != null && !string.IsNullOrWhiteSpace(cookie.Value))
77+
{
78+
try
7479
{
75-
try
76-
{
77-
var data = JsonConvert.DeserializeObject<GriddlyFilterCookieData>(cookie.Value);
78-
79-
// chrome/ff don't delete session cookies if they're set to "continue where you left off"
80-
// https://stackoverflow.com/questions/10617954/chrome-doesnt-delete-session-cookies
81-
// only use a cookie if it's new within 100 minutes
82-
if (data.CreatedUtc != null && (DateTime.UtcNow - data.CreatedUtc.Value).TotalMinutes < 100)
83-
{
84-
context.CookieData = data;
85-
context.IsDefaultSkipped = true;
80+
var data = JsonConvert.DeserializeObject<GriddlyFilterCookieData>(cookie.Value);
8681

87-
return new GriddlyCookieFilterValueProvider(context);
88-
}
89-
}
90-
catch
82+
// chrome/ff don't delete session cookies if they're set to "continue where you left off"
83+
// https://stackoverflow.com/questions/10617954/chrome-doesnt-delete-session-cookies
84+
// only use a cookie if it's new within 100 minutes
85+
if (data.CreatedUtc != null && (DateTime.UtcNow - data.CreatedUtc.Value).TotalMinutes < 100)
9186
{
92-
// TODO: log it?
87+
context.CookieData = data;
88+
context.IsDefaultSkipped = true;
89+
90+
return new GriddlyCookieFilterValueProvider(context);
9391
}
9492
}
93+
catch
94+
{
95+
// TODO: log it?
96+
}
9597
}
9698
}
9799

@@ -101,48 +103,44 @@ public override IValueProvider GetValueProvider(ControllerContext controllerCont
101103
#else
102104
public class GriddlyCookieFilterValueProviderFactory : IValueProviderFactory
103105
{
104-
Func<ActionContext, bool> _canProvide = null;
106+
Func<ActionContext, bool> _canProvide = (actionContext) => actionContext.HttpContext.Request.Query.Count == 0;
105107

106108
public GriddlyCookieFilterValueProviderFactory(Func<ActionContext, bool> canProvide = null)
107109
{
108-
_canProvide = canProvide;
110+
if (canProvide != null)
111+
_canProvide = canProvide;
109112
}
110113

111114
public Task CreateValueProviderAsync(ValueProviderFactoryContext vpfc)
112115
{
113116
return Task.Factory.StartNew(() =>
114117
{
115-
var isChildAction = vpfc.ActionContext.HttpContext.IsChildAction();
116-
117-
if (isChildAction && vpfc.ActionContext.HttpContext.Request.Query.Count == 0)
118+
if (vpfc.ActionContext.HttpContext.IsChildAction() && _canProvide.Invoke(vpfc.ActionContext))
118119
{
119-
if (_canProvide?.Invoke(vpfc.ActionContext) != false)
120-
{
121-
var context = vpfc.ActionContext.GetOrCreateGriddlyContext();
122-
var cookie = vpfc.ActionContext.HttpContext.Request.Cookies[context.CookieName];
120+
var context = vpfc.ActionContext.GetOrCreateGriddlyContext();
121+
var cookie = vpfc.ActionContext.HttpContext.Request.Cookies[context.CookieName];
123122

124-
if (cookie != null && !string.IsNullOrWhiteSpace(cookie))
123+
if (cookie != null && !string.IsNullOrWhiteSpace(cookie))
124+
{
125+
try
125126
{
126-
try
127-
{
128-
var data = JsonConvert.DeserializeObject<GriddlyFilterCookieData>(cookie);
129-
130-
// chrome/ff don't delete session cookies if they're set to "continue where you left off"
131-
// https://stackoverflow.com/questions/10617954/chrome-doesnt-delete-session-cookies
132-
// only use a cookie if it's new within 100 minutes
133-
if (data.CreatedUtc != null && (DateTime.UtcNow - data.CreatedUtc.Value).TotalMinutes < 100)
134-
{
135-
context.CookieData = data;
136-
context.IsDefaultSkipped = true;
137-
138-
vpfc.ValueProviders.Add(new GriddlyCookieFilterValueProvider(context));
139-
}
140-
}
141-
catch
127+
var data = JsonConvert.DeserializeObject<GriddlyFilterCookieData>(cookie);
128+
129+
// chrome/ff don't delete session cookies if they're set to "continue where you left off"
130+
// https://stackoverflow.com/questions/10617954/chrome-doesnt-delete-session-cookies
131+
// only use a cookie if it's new within 100 minutes
132+
if (data.CreatedUtc != null && (DateTime.UtcNow - data.CreatedUtc.Value).TotalMinutes < 100)
142133
{
143-
// TODO: log it?
134+
context.CookieData = data;
135+
context.IsDefaultSkipped = true;
136+
137+
vpfc.ValueProviders.Add(new GriddlyCookieFilterValueProvider(context));
144138
}
145139
}
140+
catch
141+
{
142+
// TODO: log it?
143+
}
146144
}
147145
}
148146
});

Griddly.Mvc/GriddlyExtensions.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,6 @@ public static GriddlyContext GetOrCreateGriddlyContext(this ControllerBase contr
492492
#else
493493
private static GriddlyContext GetOrCreateGriddlyContext(RouteData routeData, HttpContext httpContext)
494494
{
495-
//var key = _contextKey + "_" + (routeData.Values["controller"] as string).ToLower() + "_" + (routeData.Values["action"] as string).ToLower();
496495
var context = httpContext.Items[_contextKey] as GriddlyContext;
497496
#endif
498497

0 commit comments

Comments
 (0)