10
10
using System . Threading . Tasks ;
11
11
using JsonApiDotNetCore . Internal . Contracts ;
12
12
using JsonApiDotNetCore . Query ;
13
+ using JsonApiDotNetCore . Extensions ;
13
14
14
15
namespace JsonApiDotNetCore . Services
15
16
{
@@ -34,29 +35,26 @@ public class DefaultResourceService<TResource, TId> :
34
35
private readonly ResourceContext _currentRequestResource ;
35
36
36
37
public DefaultResourceService (
37
- ISortService sortService ,
38
- IFilterService filterService ,
38
+ IEnumerable < IQueryParameterService > queryParameters ,
39
39
IJsonApiOptions options ,
40
- IIncludeService includeService ,
41
- ISparseFieldsService sparseFieldsService ,
42
- IPageService pageManager ,
43
40
IResourceRepository < TResource , TId > repository ,
44
41
IResourceContextProvider provider ,
45
42
IResourceHookExecutor hookExecutor = null ,
46
43
ILoggerFactory loggerFactory = null )
47
44
{
48
- _includeService = includeService ;
49
- _sparseFieldsService = sparseFieldsService ;
50
- _pageManager = pageManager ;
45
+ _includeService = queryParameters . FirstOrDefault < IIncludeService > ( ) ;
46
+ _sparseFieldsService = queryParameters . FirstOrDefault < ISparseFieldsService > ( ) ;
47
+ _pageManager = queryParameters . FirstOrDefault < IPageService > ( ) ;
48
+ _sortService = queryParameters . FirstOrDefault < ISortService > ( ) ;
49
+ _filterService = queryParameters . FirstOrDefault < IFilterService > ( ) ;
51
50
_options = options ;
52
- _sortService = sortService ;
53
- _filterService = filterService ;
54
51
_repository = repository ;
55
52
_hookExecutor = hookExecutor ;
56
53
_logger = loggerFactory ? . CreateLogger < DefaultResourceService < TResource , TId > > ( ) ;
57
54
_currentRequestResource = provider . GetResourceContext < TResource > ( ) ;
58
55
}
59
56
57
+
60
58
public virtual async Task < TResource > CreateAsync ( TResource entity )
61
59
{
62
60
entity = IsNull ( _hookExecutor ) ? entity : _hookExecutor . BeforeCreate ( AsList ( entity ) , ResourcePipeline . Post ) . SingleOrDefault ( ) ;
@@ -323,12 +321,12 @@ public class DefaultResourceService<TResource> : DefaultResourceService<TResourc
323
321
IResourceService < TResource >
324
322
where TResource : class , IIdentifiable < int >
325
323
{
326
- public DefaultResourceService ( ISortService sortService , IFilterService filterService , IResourceRepository < TResource , int > repository ,
327
- IJsonApiOptions options , IIncludeService includeService , ISparseFieldsService sparseFieldsService ,
328
- IPageService pageManager , IResourceContextProvider provider ,
329
- IResourceHookExecutor hookExecutor = null , ILoggerFactory loggerFactory = null )
330
- : base ( sortService , filterService , options , includeService , sparseFieldsService , pageManager , repository , provider , hookExecutor , loggerFactory )
331
- {
332
- }
324
+ public DefaultResourceService ( IEnumerable < IQueryParameterService > queryParameters ,
325
+ IJsonApiOptions options ,
326
+ IResourceRepository < TResource , int > repository ,
327
+ IResourceContextProvider provider ,
328
+ IResourceHookExecutor hookExecutor = null ,
329
+ ILoggerFactory loggerFactory = null )
330
+ : base ( queryParameters , options , repository , provider , hookExecutor , loggerFactory ) { }
333
331
}
334
332
}
0 commit comments