Merge branch 'release/fix-serialization-contract'
This commit is contained in:
commit
74e16d8560
@ -60,7 +60,8 @@ namespace PoweredSoft.DynamicQuery.AspNetCore.Json
|
||||
}
|
||||
|
||||
var filterObj = ServiceProvider.GetService(isComposite ? typeof(ICompositeFilter) : typeof(ISimpleFilter));
|
||||
filterObj = jo.ToObject(filterObj.GetType());
|
||||
var filterType = filterObj.GetType();
|
||||
filterObj = jo.ToObject(filterType, serializer);
|
||||
return filterObj;
|
||||
}
|
||||
|
||||
|
34
PoweredSoft.DynamicQuery.Test/DeserializeTests.cs
Normal file
34
PoweredSoft.DynamicQuery.Test/DeserializeTests.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using PoweredSoft.DynamicQuery.AspNetCore.Json;
|
||||
using PoweredSoft.DynamicQuery.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Xunit;
|
||||
|
||||
namespace PoweredSoft.DynamicQuery.Test
|
||||
{
|
||||
public class SerializationTests
|
||||
{
|
||||
[Fact]
|
||||
public void QueryCriteria()
|
||||
{
|
||||
var json = @"{""page"":1,""pageSize"":20,""filters"":[{""type"":""composite"",""filters"":[{""path"":""title"",""value"":""Qui"",""type"":""StartsWith"",""and"":false}]}]}";
|
||||
|
||||
var serviceCollection = new ServiceCollection();
|
||||
serviceCollection.AddPoweredSoftDynamicQuery();
|
||||
var serviceProvider = serviceCollection.BuildServiceProvider();
|
||||
|
||||
var settings = new JsonSerializerSettings();
|
||||
settings.Converters.Add(new StringEnumConverter());
|
||||
settings.Converters.Add(new DynamicQueryJsonConverter(serviceProvider));
|
||||
|
||||
var data = JsonConvert.DeserializeObject<IQueryCriteria>(json, settings);
|
||||
Assert.NotNull(data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -17,6 +17,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\PoweredSoft.DynamicQuery.AspNetCore\PoweredSoft.DynamicQuery.AspNetCore.csproj" />
|
||||
<ProjectReference Include="..\PoweredSoft.DynamicQuery\PoweredSoft.DynamicQuery.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user