以下方法设置为返回实现 IResultSchema
方法:
public async Task<IResultSchema<IEmployeeSchema>> GetEmployees(int customerId, string token, int take, int skip, string direction, string column, string query)
{
if (token.IsTokenValid())
{
string endpoint;
//Stuff for setting the endpoint string here
var apiResponse = await CallApi<int, ResultSchema<EmployeeSchema>>(Enums.Method.Get, endpoint, token, default(int));
if (apiResponse.HasError) return null;
return apiResponse.Response;
}
return null;
}
IResultSchema 和 IEmployeeSchema:
public interface IResultSchema<T>
{
IEnumerable<T> Records { get; set; }
int Total { get; set; }
}
public interface IEmployeeSchema
{
IEnumerable<IApplicationSchema> Applications { get; set; }
//Rest of the props here
}
IResultSchema 和 IEmployeeSchema 的实现:
public class ResultSchema<T> : IResultSchema<T>
{
public ResultSchema()
{
Records = new List<T>();
}
public IEnumerable<T> Records { get; set; }
public int Total { get; set; }
}
public sealed class EmployeeSchema : IEmployeeSchema
{
public EmployeeSchema()
{
Applications = new List<ApplicationSchema>();
}
public IEnumerable<IApplicationSchema> Applications { get; set; }
//Rest of the props here
}