SievePropertyMapper for #4

This commit is contained in:
Biarity
2018-02-10 15:37:04 +10:00
parent b52362e2bc
commit 0bd38b8348
10 changed files with 330 additions and 10 deletions

View File

@@ -0,0 +1,28 @@
using Microsoft.Extensions.Options;
using Sieve.Models;
using Sieve.Services;
using SieveTests.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace SieveTests.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.Title)
.CanSort()
.CanFilter()
.HasName("CustomTitleName");
return mapper;
}
}
}

View File

@@ -37,7 +37,7 @@ namespace SieveTests
services.AddScoped<ISieveCustomSortMethods, SieveCustomSortMethods>();
services.AddScoped<ISieveCustomFilterMethods, SieveCustomFilterMethods>();
services.AddScoped<ISieveProcessor, SieveProcessor>();
services.AddScoped<ISieveProcessor, ApplicationSieveProcessor>();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.