public class ApiResult<T> where T : class
{
public bool Success { get; set; }
public T Data { get; set; }
}
public class ApiResult : ApiResult<object>
{
}
public static class HttpResponseExtensions
{
public static ApiResult ParseApiResult(this HttpResponse response)
{
// I cannot do this because ApiResult<object> is not compatible with ApiResult<T>
return response.Headers["Structure"] switch
{
"text" => response.ParseString(),
"list" => response.ParseList(),
"table" => response.ParseTable(),
_ => null
};
}
private static ApiResult<List<string>> ParseList(this HttpResponse response)
{
return new ApiResult<List<string>>();
}
private static ApiResult<string> ParseString(this HttpResponse response)
{
return new ApiResult<string>();
}
private static ApiResult<List<List<string>>> ParseTable(this HttpResponse response)
{
return new ApiResult<List<List<string>>>();
}
}
public class ApiResult<T> where T : class
{
public bool Success { get; set; }
public T Data { get; set; }
}
public class ApiResult : ApiResult<object>
{
}
public static class HttpResponseExtensions
{
public static ApiResult ParseApiResult(this HttpResponse response)
{
// I cannot do this because ApiResult<object> is not compatible with ApiResult<T>
return response.Headers["Structure"] switch
{
"text" => response.ParseString(),
"list" => response.ParseList(),
"table" => response.ParseTable(),
_ => null
};
}
private static ApiResult<List<string>> ParseList(this HttpResponse response)
{
return new ApiResult<List<string>>();
}
private static ApiResult<string> ParseString(this HttpResponse response)
{
return new ApiResult<string>();
}
private static ApiResult<List<List<string>>> ParseTable(this HttpResponse response)
{
return new ApiResult<List<List<string>>>();
}
}