Sieve/SieveUnitTests/Services/ApplicationSieveProcessor.cs

80 lines
2.3 KiB
C#
Raw Permalink Normal View History

2018-02-10 06:37:04 +01:00
using Microsoft.Extensions.Options;
using Sieve.Models;
using Sieve.Services;
using SieveUnitTests.Abstractions.Entity;
2018-02-10 06:37:04 +01:00
using SieveUnitTests.Entities;
namespace SieveUnitTests.Services
{
2019-11-17 00:15:07 +01:00
public class ApplicationSieveProcessor : SieveProcessor
2018-02-10 06:37:04 +01:00
{
2018-02-10 07:10:50 +01:00
public ApplicationSieveProcessor(
2018-05-15 01:34:37 +02:00
IOptions<SieveOptions> options,
ISieveCustomSortMethods customSortMethods,
ISieveCustomFilterMethods customFilterMethods)
2018-02-10 07:10:50 +01:00
: base(options, customSortMethods, customFilterMethods)
2018-02-10 06:37:04 +01:00
{
}
protected override SievePropertyMapper MapProperties(SievePropertyMapper mapper)
{
mapper.Property<Post>(p => p.ThisHasNoAttributeButIsAccessible)
.CanSort()
.CanFilter()
.HasName("shortname");
2019-01-18 11:45:38 +01:00
mapper.Property<Post>(p => p.TopComment.Text)
.CanFilter();
mapper.Property<Post>(p => p.TopComment.Id)
.CanSort();
2018-02-10 06:37:04 +01:00
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");
2018-02-10 06:37:04 +01:00
return mapper;
}
}
}