-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from trenoncourt/develop
add wrap total-count & fix disallowed/allowed clauses
- Loading branch information
Showing
34 changed files
with
363 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/AutoQueryable.Extensions.Autofac/AutoQueryable.Extensions.Autofac.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ryable.Extensions.DependencyInjection/AutoQueryable.Extensions.DependencyInjection.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
src/AutoQueryable/Core/Clauses/ClauseHandlers/DefaultOrderByClauseHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/AutoQueryable/Core/Clauses/ClauseHandlers/IClauseHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
src/AutoQueryable/Core/Clauses/ClauseHandlers/IOrderByClauseHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
src/AutoQueryable/Core/Clauses/ClauseHandlers/ISelectClauseHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
src/AutoQueryable/Core/Clauses/ClauseHandlers/IWrapWithClauseHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,75 @@ | ||
using System.Text.RegularExpressions; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using AutoQueryable.Core.Aliases; | ||
using AutoQueryable.Core.Clauses.ClauseHandlers; | ||
using AutoQueryable.Core.Enums; | ||
using AutoQueryable.Core.Models; | ||
|
||
namespace AutoQueryable.Core.Clauses | ||
{ | ||
public class ClauseMapManager : IClauseMapManager | ||
{ | ||
private readonly IClauseQueryFilterMap _clauseQueryFilterMap; | ||
private readonly ISelectClauseHandler _selectClauseHandler; | ||
private readonly IOrderByClauseHandler _orderByClauseHandler; | ||
private readonly IWrapWithClauseHandler _wrapWithClauseHandler; | ||
private readonly IAutoQueryableProfile _autoQueryableProfile; | ||
private readonly ICollection<IClauseQueryFilter> _queryFilters = new List<IClauseQueryFilter>(); | ||
|
||
public ClauseMapManager(ISelectClauseHandler selectClauseHandler, IOrderByClauseHandler orderByClauseHandler, IWrapWithClauseHandler wrapWithClauseHandler) | ||
public ClauseMapManager(ISelectClauseHandler selectClauseHandler, IOrderByClauseHandler orderByClauseHandler, IWrapWithClauseHandler wrapWithClauseHandler, IAutoQueryableProfile autoQueryableProfile) | ||
{ | ||
_clauseQueryFilterMap = new DefaultClauseQueryFilterMap(selectClauseHandler, orderByClauseHandler, wrapWithClauseHandler); | ||
_selectClauseHandler = selectClauseHandler; | ||
_orderByClauseHandler = orderByClauseHandler; | ||
_wrapWithClauseHandler = wrapWithClauseHandler; | ||
_autoQueryableProfile = autoQueryableProfile; | ||
} | ||
|
||
public IClauseQueryFilter GetClauseQueryFilter(string alias) | ||
=> _clauseQueryFilterMap.GetClauseQueryFilter(alias); | ||
public void Init() | ||
{ | ||
if (_autoQueryableProfile.IsClauseAllowed(ClauseType.Select)) | ||
{ | ||
_queryFilters.Add(new DefaultClauseQueryFilter(ClauseAlias.Select, ClauseType.Select, _selectClauseHandler.Handle)); | ||
} | ||
if (_autoQueryableProfile.IsClauseAllowed(ClauseType.Top)) | ||
{ | ||
_queryFilters.Add(new DefaultClauseQueryFilter(ClauseAlias.Top, ClauseType.Top, (value, type, profile) => int.Parse(value))); | ||
_queryFilters.Add(new DefaultClauseQueryFilter(ClauseAlias.Take, ClauseType.Top, (value, type, profile) => int.Parse(value))); | ||
} | ||
if (_autoQueryableProfile.IsClauseAllowed(ClauseType.Skip)) | ||
{ | ||
_queryFilters.Add(new DefaultClauseQueryFilter(ClauseAlias.Skip, ClauseType.Skip, (value, type, profile) => int.Parse(value))); | ||
} | ||
if (_autoQueryableProfile.IsClauseAllowed(ClauseType.First)) | ||
{ | ||
_queryFilters.Add(new DefaultClauseQueryFilter(ClauseAlias.First, ClauseType.First)); | ||
} | ||
if (_autoQueryableProfile.IsClauseAllowed(ClauseType.Last)) | ||
{ | ||
_queryFilters.Add(new DefaultClauseQueryFilter(ClauseAlias.Last, ClauseType.Last)); | ||
} | ||
if (_autoQueryableProfile.IsClauseAllowed(ClauseType.OrderBy)) | ||
{ | ||
_queryFilters.Add(new DefaultClauseQueryFilter(ClauseAlias.OrderBy, ClauseType.OrderBy, _orderByClauseHandler.Handle)); | ||
} | ||
if (_autoQueryableProfile.IsClauseAllowed(ClauseType.GroupBy)) | ||
{ | ||
_queryFilters.Add(new DefaultClauseQueryFilter(ClauseAlias.GroupBy, ClauseType.GroupBy)); | ||
} | ||
if (_autoQueryableProfile.IsClauseAllowed(ClauseType.Page)) | ||
{ | ||
_queryFilters.Add(new DefaultClauseQueryFilter(ClauseAlias.Page, ClauseType.Page, (value, type, profile) => int.Parse(value))); | ||
} | ||
if (_autoQueryableProfile.IsClauseAllowed(ClauseType.PageSize)) | ||
{ | ||
_queryFilters.Add(new DefaultClauseQueryFilter(ClauseAlias.PageSize, ClauseType.PageSize, (value, type, profile) => int.Parse(value))); | ||
} | ||
if (_autoQueryableProfile.IsClauseAllowed(ClauseType.WrapWith)) | ||
{ | ||
_queryFilters.Add(new DefaultClauseQueryFilter(ClauseAlias.WrapWith, ClauseType.WrapWith, _wrapWithClauseHandler.Handle)); | ||
} | ||
} | ||
|
||
public IClauseQueryFilter GetClauseQueryFilter(ClauseType clauseType) => _clauseQueryFilterMap.GetClauseQueryFilter(clauseType); | ||
public IClauseQueryFilter GetClauseQueryFilter(ClauseType clauseType) => _queryFilters.FirstOrDefault(f => f.ClauseType == clauseType); | ||
|
||
public IClauseQueryFilter FindClauseQueryFilter(string queryParameterKey) | ||
=> _clauseQueryFilterMap.FindClauseQueryFilter(queryParameterKey); | ||
private string GetOperandValue(string q, string clauseAlias) => Regex.Split(q, clauseAlias, RegexOptions.IgnoreCase)[1]; | ||
public IClauseQueryFilter FindClauseQueryFilter(string queryParameterKey) => _queryFilters.FirstOrDefault(clause => queryParameterKey.Contains(clause.Alias.ToLowerInvariant())); | ||
} | ||
} |
35 changes: 0 additions & 35 deletions
35
src/AutoQueryable/Core/Clauses/DefaultClauseQueryFilterMap.cs
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
using AutoQueryable.Core.Enums; | ||
using AutoQueryable.Core.Models; | ||
|
||
namespace AutoQueryable.Core.Clauses | ||
{ | ||
public interface IClauseMapManager | ||
{ | ||
void Init(); | ||
IClauseQueryFilter FindClauseQueryFilter(string queryParameterKey); | ||
IClauseQueryFilter GetClauseQueryFilter(string alias); | ||
IClauseQueryFilter GetClauseQueryFilter(ClauseType clauseType); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
3 changes: 1 addition & 2 deletions
3
src/AutoQueryable/Core/CriteriaFilters/FilterMaps/StringFilterMapFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.