-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataGridSortParser.cs
More file actions
27 lines (25 loc) · 936 Bytes
/
DataGridSortParser.cs
File metadata and controls
27 lines (25 loc) · 936 Bytes
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
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Web;
namespace DevExGridEnhancer
{
/// <summary>
/// Helper class for parsing and processing DataGrid sort parameters.
/// </summary>
public static class DataGridSortParser
{
/// <summary>
/// Parses the sorting information from a URL-encoded JSON string.
/// </summary>
/// <param name="sort">The URL-encoded JSON string containing sorting information.</param>
/// <returns>An enumerable of <see cref="DataGridSortModel"/>.</returns>
public static IEnumerable<DataGridSortModel> ParseSorts(string sort)
{
if (string.IsNullOrEmpty(sort))
return Enumerable.Empty<DataGridSortModel>();
return JsonSerializer.Deserialize<List<DataGridSortModel>>(HttpUtility.UrlDecode(sort, Encoding.UTF8));
}
}
}