2018-02-10 06:37:04 +01:00
|
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
|
using Sieve.Models;
|
2021-05-13 14:04:18 +02:00
|
|
|
|
using Sieve.Sample.Entities;
|
2018-02-10 06:37:04 +01:00
|
|
|
|
using Sieve.Services;
|
|
|
|
|
|
2021-05-13 14:04:18 +02:00
|
|
|
|
namespace Sieve.Sample.Services
|
2018-02-10 06:37:04 +01:00
|
|
|
|
{
|
2019-11-17 00:15:07 +01:00
|
|
|
|
public class ApplicationSieveProcessor : SieveProcessor
|
2018-02-10 06:37:04 +01:00
|
|
|
|
{
|
|
|
|
|
public ApplicationSieveProcessor(IOptions<SieveOptions> options, ISieveCustomSortMethods customSortMethods, ISieveCustomFilterMethods customFilterMethods) : base(options, customSortMethods, customFilterMethods)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override SievePropertyMapper MapProperties(SievePropertyMapper mapper)
|
|
|
|
|
{
|
2022-01-12 20:22:24 +01:00
|
|
|
|
// Option 1: Map all properties centrally
|
2018-02-10 06:37:04 +01:00
|
|
|
|
mapper.Property<Post>(p => p.Title)
|
|
|
|
|
.CanSort()
|
|
|
|
|
.CanFilter()
|
|
|
|
|
.HasName("CustomTitleName");
|
|
|
|
|
|
2022-01-12 20:22:24 +01:00
|
|
|
|
// Option 2: Manually apply functionally grouped mapping configurations
|
|
|
|
|
//mapper.ApplyConfiguration<SieveConfigurationForPost>();
|
|
|
|
|
|
|
|
|
|
// Option 3: Scan and apply all configurations
|
|
|
|
|
//mapper.ApplyConfigurationsFromAssembly(typeof(ApplicationSieveProcessor).Assembly);
|
|
|
|
|
|
2018-02-10 06:37:04 +01:00
|
|
|
|
return mapper;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|