add generic constraint

This commit is contained in:
Collin M. Barrett 2019-07-12 17:20:05 -05:00
parent 9a524d574b
commit e798b344df
2 changed files with 2 additions and 1 deletions

View file

@ -7,6 +7,6 @@ namespace FilterLists.Agent.Core.Urls
{
public interface IUrlRepository
{
Task<IEnumerable<Uri>> GetAllAsync<TModel>(CancellationToken cancellationToken);
Task<IEnumerable<Uri>> GetAllAsync<TModel>(CancellationToken cancellationToken) where TModel : class, new();
}
}

View file

@ -33,6 +33,7 @@ public UrlRepository(IFilterListsApiClient apiClient, IStringLocalizer<UrlReposi
}
public async Task<IEnumerable<Uri>> GetAllAsync<TModel>(CancellationToken cancellationToken)
where TModel : class, new()
{
if (!EntityUrlsEndpoints.ContainsKey(typeof(TModel).Name))
throw new ArgumentException(_localizer["The type of TModel is not valid."]);