I am using a custom JsonConverter. And I need to get type of an object and set in as generic parameter.
public class PagedResultConverter : Newtonsoft.Json.JsonConverter
{
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var pagedList = (IPagedList<T>)value;
var jsonJObject = new JObject
{
{"TotalCount", pagedList.TotalCount}
}
jsonJObject.WriteTo(writer);
}
}
My IPagedList<T>
parameter T
will be type of typeof(value)
But I can not set IPagedList<typeof(value)>
I need to get properties, members of interface.
How can I do this?