public QueryResponse<T>? GetSomething<T>()
{
Type dtoType = new T().GetDTOType(); // This will be a different type, but one that a T can be created from
Type receiveType = typeof(QueryResponse<dtoType>);
QueryResponse<dtoType>? result = (QueryResponse<dtoType>)JsonSerializer.Deserialize(content, receiveType);
if(result is null)
{
return null;
}
return new QueryResponse<T>()
{
Data = new T(result.Data),
Success = true
};
}
public QueryResponse<T>? GetSomething<T>()
{
Type dtoType = new T().GetDTOType(); // This will be a different type, but one that a T can be created from
Type receiveType = typeof(QueryResponse<dtoType>);
QueryResponse<dtoType>? result = (QueryResponse<dtoType>)JsonSerializer.Deserialize(content, receiveType);
if(result is null)
{
return null;
}
return new QueryResponse<T>()
{
Data = new T(result.Data),
Success = true
};
}