mirror of
https://github.com/Biarity/Sieve.git
synced 2024-11-23 05:52:45 +01:00
a4509bb8f0
SieveProcessor is modified to pass propertyInfo to OrderByDynamic to avoid reattainment of propertyInfo required in Expression.MakeMemberAccess. SieveProcessor is modified to be able to handle possible multiple incompatible customMethods via AggregateException. Corresponding interfaces are generated for entities with related inheritance. ApplicationSieveProcessor is modified to include interface members. SieveCustomFilterMethods and SieveCustomSortMethod are modified to include interface related custom method modifications. Interface accessed unit tests are added.
80 lines
2.3 KiB
C#
80 lines
2.3 KiB
C#
using Microsoft.Extensions.Options;
|
|
using Sieve.Models;
|
|
using Sieve.Services;
|
|
using SieveUnitTests.Abstractions.Entity;
|
|
using SieveUnitTests.Entities;
|
|
|
|
namespace SieveUnitTests.Services
|
|
{
|
|
public class ApplicationSieveProcessor : SieveProcessor
|
|
{
|
|
public ApplicationSieveProcessor(
|
|
IOptions<SieveOptions> options,
|
|
ISieveCustomSortMethods customSortMethods,
|
|
ISieveCustomFilterMethods customFilterMethods)
|
|
: base(options, customSortMethods, customFilterMethods)
|
|
{
|
|
}
|
|
|
|
protected override SievePropertyMapper MapProperties(SievePropertyMapper mapper)
|
|
{
|
|
mapper.Property<Post>(p => p.ThisHasNoAttributeButIsAccessible)
|
|
.CanSort()
|
|
.CanFilter()
|
|
.HasName("shortname");
|
|
|
|
mapper.Property<Post>(p => p.TopComment.Text)
|
|
.CanFilter();
|
|
|
|
mapper.Property<Post>(p => p.TopComment.Id)
|
|
.CanSort();
|
|
|
|
mapper.Property<Post>(p => p.OnlySortableViaFluentApi)
|
|
.CanSort();
|
|
|
|
mapper.Property<Post>(p => p.TopComment.Text)
|
|
.CanFilter()
|
|
.HasName("topc");
|
|
|
|
mapper.Property<Post>(p => p.FeaturedComment.Text)
|
|
.CanFilter()
|
|
.HasName("featc");
|
|
|
|
mapper
|
|
.Property<Post>(p => p.DateCreated)
|
|
.CanSort()
|
|
.HasName("CreateDate");
|
|
|
|
// interfaces
|
|
mapper.Property<IPost>(p => p.ThisHasNoAttributeButIsAccessible)
|
|
.CanSort()
|
|
.CanFilter()
|
|
.HasName("shortname");
|
|
|
|
mapper.Property<IPost>(p => p.TopComment.Text)
|
|
.CanFilter();
|
|
|
|
mapper.Property<IPost>(p => p.TopComment.Id)
|
|
.CanSort();
|
|
|
|
mapper.Property<IPost>(p => p.OnlySortableViaFluentApi)
|
|
.CanSort();
|
|
|
|
mapper.Property<IPost>(p => p.TopComment.Text)
|
|
.CanFilter()
|
|
.HasName("topc");
|
|
|
|
mapper.Property<IPost>(p => p.FeaturedComment.Text)
|
|
.CanFilter()
|
|
.HasName("featc");
|
|
|
|
mapper
|
|
.Property<IPost>(p => p.DateCreated)
|
|
.CanSort()
|
|
.HasName("CreateDate");
|
|
|
|
return mapper;
|
|
}
|
|
}
|
|
}
|