-
-
Notifications
You must be signed in to change notification settings - Fork 158
Consider simplifying constructor signatures in controller/repo/service layer #568
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Controller layer
Service layer
Repo layer
|
ResourceGraph
dependency in controller
We could consider to do something like this. Instead of public DefaultResourceService(
ISortService sortService,
IFilterService filterService,
IIncludeService includeService,
ISparseFieldsService sparseFieldsService,
IPageService pageManager,
IJsonApiOptions options,
IResourceRepository<TResource, TId> repository,
IResourceContextProvider provider,
IResourceHookExecutor hookExecutor = null,
ILoggerFactory loggerFactory = null)
{
_includeService = includeService;
_sparseFieldsService = sparseFieldsService;
_pageManager = pageManager;
_options = options;
_sortService = sortService;
_filterService = filterService;
_repository = repository;
_hookExecutor = hookExecutor;
_logger = loggerFactory?.CreateLogger<DefaultResourceService<TResource, TId>>();
_currentRequestResource = provider.GetResourceContext<TResource>();
}
public DefaultResourceService(IEnumerable<IQueryParameterService> queryServices, ....) we could do public DefaultResourceService(
IEnumerable<IQueryParameterService> queryParameters
IJsonApiOptions options,
IResourceRepository<TResource, TId> repository,
IResourceContextProvider provider,
IResourceHookExecutor hookExecutor = null,
ILoggerFactory loggerFactory = null)
{
_includeService = queryParameters.Single(qp => qp is IIncludedService);
_sparseFieldsService = queryParameters.Single(qp => qp is ISparseFieldsService);
_pageManager = queryParameters.Single(qp => qp is IPageService);
_sortService = queryParameters.Single(qp => qp is ISortService);
_filterService = queryParameters.Single(qp => qp is IFilterService);
_repository = repository;
_options = options;
_hookExecutor = hookExecutor;
_logger = loggerFactory?.CreateLogger<DefaultResourceService<TResource, TId>>();
_currentRequestResource = provider.GetResourceContext<TResource>();
} This would allow for a more extensibility and future features without having to introduce breaking changes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Its only needed here:
JsonApiDotNetCore/src/JsonApiDotNetCore/Controllers/BaseJsonApiController.cs
Lines 158 to 160 in 8570b21
So.. we might be able to get rid of that.
The text was updated successfully, but these errors were encountered: