mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
ren generic type param
This commit is contained in:
parent
63b33a20ac
commit
9e9bb5ebfd
2 changed files with 7 additions and 7 deletions
|
|
@ -6,6 +6,6 @@ namespace FilterLists.Agent.Core.Interfaces
|
|||
{
|
||||
public interface IUrlsRepository
|
||||
{
|
||||
Task<IEnumerable<Uri>> GetAllAsync<TEntityUrls>();
|
||||
Task<IEnumerable<Uri>> GetAllAsync<TModel>();
|
||||
}
|
||||
}
|
||||
|
|
@ -18,20 +18,20 @@ public UrlsRepository(IFilterListsApiClient apiClient)
|
|||
_apiClient = apiClient;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Uri>> GetAllAsync<TEntityUrls>()
|
||||
public async Task<IEnumerable<Uri>> GetAllAsync<TModel>()
|
||||
{
|
||||
var endpoint = BuildEndpoint<TEntityUrls>();
|
||||
var endpoint = BuildEndpoint<TModel>();
|
||||
var request = new RestRequest(endpoint);
|
||||
var response = await _apiClient.ExecuteAsync<IEnumerable<TEntityUrls>>(request);
|
||||
var response = await _apiClient.ExecuteAsync<IEnumerable<TModel>>(request);
|
||||
return response.SelectMany(r =>
|
||||
r.GetType().GetProperties().Where(p => p.GetType() == typeof(Uri)).Select(p => (Uri)p.GetValue(r)))
|
||||
.Where(u => u != null);
|
||||
}
|
||||
|
||||
private static string BuildEndpoint<TEntityUrls>()
|
||||
private static string BuildEndpoint<TModel>()
|
||||
{
|
||||
string endpointSuffix;
|
||||
switch (typeof(TEntityUrls).Name)
|
||||
switch (typeof(TModel).Name)
|
||||
{
|
||||
case nameof(SyntaxUrls):
|
||||
endpointSuffix = "es";
|
||||
|
|
@ -44,7 +44,7 @@ private static string BuildEndpoint<TEntityUrls>()
|
|||
break;
|
||||
}
|
||||
|
||||
return $"{typeof(TEntityUrls).Name.Replace("Urls", endpointSuffix).ToLowerInvariant()}/seed";
|
||||
return $"{typeof(TModel).Name.Replace("Urls", endpointSuffix).ToLowerInvariant()}/seed";
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue