Ejemplo n.º 1
0
 public QueryableBuilder(Expression source, Type elementType, Type extensionType, LambdaParameterNameFactory nameFactory,
                         IResourceFactory resourceFactory, IResourceContextProvider resourceContextProvider, IModel entityModel,
                         LambdaScopeFactory lambdaScopeFactory = null)
 {
     _source                  = source ?? throw new ArgumentNullException(nameof(source));
     _elementType             = elementType ?? throw new ArgumentNullException(nameof(elementType));
     _extensionType           = extensionType ?? throw new ArgumentNullException(nameof(extensionType));
     _nameFactory             = nameFactory ?? throw new ArgumentNullException(nameof(nameFactory));
     _resourceFactory         = resourceFactory ?? throw new ArgumentNullException(nameof(resourceFactory));
     _resourceContextProvider = resourceContextProvider ?? throw new ArgumentNullException(nameof(resourceContextProvider));
     _entityModel             = entityModel ?? throw new ArgumentNullException(nameof(entityModel));
     _lambdaScopeFactory      = lambdaScopeFactory ?? new LambdaScopeFactory(_nameFactory);
 }
Ejemplo n.º 2
0
 public QueryLayerComposer(
     IEnumerable <IQueryConstraintProvider> constraintProviders,
     IResourceContextProvider resourceContextProvider,
     IResourceDefinitionProvider resourceDefinitionProvider,
     IJsonApiOptions options,
     IPaginationContext paginationContext)
 {
     _constraintProviders        = constraintProviders ?? throw new ArgumentNullException(nameof(constraintProviders));
     _resourceContextProvider    = resourceContextProvider ?? throw new ArgumentNullException(nameof(resourceContextProvider));
     _resourceDefinitionProvider = resourceDefinitionProvider ?? throw new ArgumentNullException(nameof(resourceDefinitionProvider));
     _options           = options ?? throw new ArgumentNullException(nameof(options));
     _paginationContext = paginationContext ?? throw new ArgumentNullException(nameof(paginationContext));
 }
Ejemplo n.º 3
0
        public JsonApiReader(IJsonApiDeserializer deserializer, IJsonApiRequest request, IResourceContextProvider resourceContextProvider,
                             ILoggerFactory loggerFactory)
        {
            ArgumentGuard.NotNull(deserializer, nameof(deserializer));
            ArgumentGuard.NotNull(request, nameof(request));
            ArgumentGuard.NotNull(resourceContextProvider, nameof(resourceContextProvider));
            ArgumentGuard.NotNull(loggerFactory, nameof(loggerFactory));

            _deserializer            = deserializer;
            _request                 = request;
            _resourceContextProvider = resourceContextProvider;
            _traceWriter             = new TraceLogWriter <JsonApiReader>(loggerFactory);
        }
 public RequestDeserializer(
     IResourceContextProvider resourceContextProvider,
     IResourceFactory resourceFactory,
     ITargetedFields targetedFields,
     IHttpContextAccessor httpContextAccessor,
     IJsonApiRequest request,
     IJsonApiOptions options)
     : base(resourceContextProvider, resourceFactory)
 {
     _targetedFields      = targetedFields ?? throw new ArgumentNullException(nameof(targetedFields));
     _httpContextAccessor = httpContextAccessor ?? throw new ArgumentNullException(nameof(httpContextAccessor));
     _request             = request ?? throw new ArgumentNullException(nameof(request));
     _options             = options ?? throw new ArgumentNullException(nameof(options));
 }
 public ResponseSerializer(IMetaBuilder <TResource> metaBuilder,
                           ILinkBuilder linkBuilder,
                           IIncludedResourceObjectBuilder includedBuilder,
                           IFieldsToSerialize fieldsToSerialize,
                           IResourceObjectBuilder resourceObjectBuilder,
                           IResourceContextProvider provider) :
     base(resourceObjectBuilder, provider)
 {
     _fieldsToSerialize   = fieldsToSerialize;
     _linkBuilder         = linkBuilder;
     _metaBuilder         = metaBuilder;
     _includedBuilder     = includedBuilder;
     _primaryResourceType = typeof(TResource);
 }
Ejemplo n.º 6
0
 public ResponseResourceObjectBuilder(ILinkBuilder linkBuilder,
                                      IIncludedResourceObjectBuilder includedBuilder,
                                      IEnumerable <IQueryConstraintProvider> constraintProviders,
                                      IResourceContextProvider resourceContextProvider,
                                      IResourceDefinitionAccessor resourceDefinitionAccessor,
                                      IResourceObjectBuilderSettingsProvider settingsProvider)
     : base(resourceContextProvider, settingsProvider.Get())
 {
     _linkBuilder                = linkBuilder ?? throw new ArgumentNullException(nameof(linkBuilder));
     _includedBuilder            = includedBuilder ?? throw new ArgumentNullException(nameof(includedBuilder));
     _constraintProviders        = constraintProviders ?? throw new ArgumentNullException(nameof(constraintProviders));
     _resourceDefinitionAccessor = resourceDefinitionAccessor ?? throw new ArgumentNullException(nameof(resourceDefinitionAccessor));
     _sparseFieldSetCache        = new SparseFieldSetCache(constraintProviders, resourceDefinitionAccessor);
 }
 public IncludedResourceObjectBuilder(IFieldsToSerialize fieldsToSerialize,
                                      ILinkBuilder linkBuilder,
                                      IResourceContextProvider resourceContextProvider,
                                      IEnumerable <IQueryConstraintProvider> constraintProviders,
                                      IResourceDefinitionAccessor resourceDefinitionAccessor,
                                      IResourceObjectBuilderSettingsProvider settingsProvider)
     : base(resourceContextProvider, settingsProvider.Get())
 {
     _included                   = new HashSet <ResourceObject>(ResourceIdentifierObjectComparer.Instance);
     _fieldsToSerialize          = fieldsToSerialize ?? throw new ArgumentNullException(nameof(fieldsToSerialize));
     _linkBuilder                = linkBuilder ?? throw new ArgumentNullException(nameof(linkBuilder));
     _resourceDefinitionAccessor = resourceDefinitionAccessor ?? throw new ArgumentNullException(nameof(resourceDefinitionAccessor));
     _sparseFieldSetCache        = new SparseFieldSetCache(constraintProviders, resourceDefinitionAccessor);
 }
        public RequestDeserializer(IResourceContextProvider resourceContextProvider, IResourceFactory resourceFactory, ITargetedFields targetedFields,
                                   IHttpContextAccessor httpContextAccessor, IJsonApiRequest request, IJsonApiOptions options)
            : base(resourceContextProvider, resourceFactory)
        {
            ArgumentGuard.NotNull(targetedFields, nameof(targetedFields));
            ArgumentGuard.NotNull(httpContextAccessor, nameof(httpContextAccessor));
            ArgumentGuard.NotNull(request, nameof(request));
            ArgumentGuard.NotNull(options, nameof(options));

            _targetedFields      = targetedFields;
            _httpContextAccessor = httpContextAccessor;
            _request             = request;
            _options             = options;
        }
Ejemplo n.º 9
0
        public LinkBuilder(IJsonApiOptions options, IJsonApiRequest request, IPaginationContext paginationContext, IResourceContextProvider provider,
                           IRequestQueryStringAccessor queryStringAccessor)
        {
            ArgumentGuard.NotNull(options, nameof(options));
            ArgumentGuard.NotNull(request, nameof(request));
            ArgumentGuard.NotNull(paginationContext, nameof(paginationContext));
            ArgumentGuard.NotNull(provider, nameof(provider));
            ArgumentGuard.NotNull(queryStringAccessor, nameof(queryStringAccessor));

            _options             = options;
            _request             = request;
            _paginationContext   = paginationContext;
            _provider            = provider;
            _queryStringAccessor = queryStringAccessor;
        }
        public JsonApiReader(IJsonApiDeserializer deserializer,
                             IJsonApiRequest request,
                             IResourceContextProvider resourceContextProvider,
                             ILoggerFactory loggerFactory)
        {
            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            _deserializer            = deserializer ?? throw new ArgumentNullException(nameof(deserializer));
            _request                 = request ?? throw new ArgumentNullException(nameof(request));
            _resourceContextProvider = resourceContextProvider ?? throw new ArgumentNullException(nameof(resourceContextProvider));
            _traceWriter             = new TraceLogWriter <JsonApiReader>(loggerFactory);
        }
 public ResponseResourceObjectBuilder(IFieldsToSerialize fieldsToSerialize,
                                      ILinkBuilder linkBuilder,
                                      IIncludedResourceObjectBuilder includedBuilder,
                                      IIncludeService includeService,
                                      IResourceContextProvider provider,
                                      IResourceObjectBuilderSettingsProvider settingsProvider,
                                      ILoggerFactory loggerFactory)
     : base(provider, settingsProvider.Get())
 {
     _logger            = loggerFactory.CreateLogger <ResponseResourceObjectBuilder>();
     _linkBuilder       = linkBuilder;
     _includedBuilder   = includedBuilder;
     _includeService    = includeService;
     _fieldsToSerialize = fieldsToSerialize;
 }
 public QueryLayerComposer(
     IEnumerable <IQueryConstraintProvider> constraintProviders,
     IResourceContextProvider resourceContextProvider,
     IResourceDefinitionAccessor resourceDefinitionAccessor,
     IJsonApiOptions options,
     IPaginationContext paginationContext,
     ITargetedFields targetedFields)
 {
     _constraintProviders        = constraintProviders ?? throw new ArgumentNullException(nameof(constraintProviders));
     _resourceContextProvider    = resourceContextProvider ?? throw new ArgumentNullException(nameof(resourceContextProvider));
     _resourceDefinitionAccessor = resourceDefinitionAccessor ?? throw new ArgumentNullException(nameof(resourceDefinitionAccessor));
     _options             = options ?? throw new ArgumentNullException(nameof(options));
     _paginationContext   = paginationContext ?? throw new ArgumentNullException(nameof(paginationContext));
     _targetedFields      = targetedFields ?? throw new ArgumentNullException(nameof(targetedFields));
     _sparseFieldSetCache = new SparseFieldSetCache(constraintProviders, resourceDefinitionAccessor);
 }
Ejemplo n.º 13
0
        public async Task InvokeAsync(HttpContext httpContext, IControllerResourceMapping controllerResourceMapping, IJsonApiOptions options,
                                      IJsonApiRequest request, IResourceContextProvider resourceContextProvider)
        {
            ArgumentGuard.NotNull(httpContext, nameof(httpContext));
            ArgumentGuard.NotNull(controllerResourceMapping, nameof(controllerResourceMapping));
            ArgumentGuard.NotNull(options, nameof(options));
            ArgumentGuard.NotNull(request, nameof(request));
            ArgumentGuard.NotNull(resourceContextProvider, nameof(resourceContextProvider));

            if (!await ValidateIfMatchHeaderAsync(httpContext, options.SerializerSettings))
            {
                return;
            }

            RouteValueDictionary routeValues            = httpContext.GetRouteData().Values;
            ResourceContext      primaryResourceContext = CreatePrimaryResourceContext(httpContext, controllerResourceMapping, resourceContextProvider);

            if (primaryResourceContext != null)
            {
                if (!await ValidateContentTypeHeaderAsync(HeaderConstants.MediaType, httpContext, options.SerializerSettings) ||
                    !await ValidateAcceptHeaderAsync(MediaType, httpContext, options.SerializerSettings))
                {
                    return;
                }

                SetupResourceRequest((JsonApiRequest)request, primaryResourceContext, routeValues, options, resourceContextProvider, httpContext.Request);

                httpContext.RegisterJsonApiRequest();
            }
            else if (IsOperationsRequest(routeValues))
            {
                if (!await ValidateContentTypeHeaderAsync(HeaderConstants.AtomicOperationsMediaType, httpContext, options.SerializerSettings) ||
                    !await ValidateAcceptHeaderAsync(AtomicOperationsMediaType, httpContext, options.SerializerSettings))
                {
                    return;
                }

                SetupOperationsRequest((JsonApiRequest)request, options, httpContext.Request);

                httpContext.RegisterJsonApiRequest();
            }

            // Workaround for bug https://github.com/dotnet/aspnetcore/issues/33394
            httpContext.Features.Set <IQueryFeature>(new FixedQueryFeature(httpContext.Features));

            await _next(httpContext);
        }
        public async Task Invoke(HttpContext httpContext,
                                 IControllerResourceMapping controllerResourceMapping,
                                 IJsonApiOptions options,
                                 IJsonApiRequest request,
                                 IResourceContextProvider resourceContextProvider)
        {
            if (httpContext == null)
            {
                throw new ArgumentNullException(nameof(httpContext));
            }
            if (controllerResourceMapping == null)
            {
                throw new ArgumentNullException(nameof(controllerResourceMapping));
            }
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            if (resourceContextProvider == null)
            {
                throw new ArgumentNullException(nameof(resourceContextProvider));
            }

            var routeValues = httpContext.GetRouteData().Values;

            var primaryResourceContext = CreatePrimaryResourceContext(routeValues, controllerResourceMapping, resourceContextProvider);

            if (primaryResourceContext != null)
            {
                if (!await ValidateContentTypeHeaderAsync(httpContext, options.SerializerSettings) ||
                    !await ValidateAcceptHeaderAsync(httpContext, options.SerializerSettings))
                {
                    return;
                }

                SetupRequest((JsonApiRequest)request, primaryResourceContext, routeValues, options, resourceContextProvider, httpContext.Request);

                httpContext.RegisterJsonApiRequest();
            }

            await _next(httpContext);
        }
        public OperationsProcessor(IOperationProcessorAccessor operationProcessorAccessor, IOperationsTransactionFactory operationsTransactionFactory,
                                   ILocalIdTracker localIdTracker, IResourceContextProvider resourceContextProvider, IJsonApiRequest request, ITargetedFields targetedFields)
        {
            ArgumentGuard.NotNull(operationProcessorAccessor, nameof(operationProcessorAccessor));
            ArgumentGuard.NotNull(operationsTransactionFactory, nameof(operationsTransactionFactory));
            ArgumentGuard.NotNull(localIdTracker, nameof(localIdTracker));
            ArgumentGuard.NotNull(resourceContextProvider, nameof(resourceContextProvider));
            ArgumentGuard.NotNull(request, nameof(request));
            ArgumentGuard.NotNull(targetedFields, nameof(targetedFields));

            _operationProcessorAccessor   = operationProcessorAccessor;
            _operationsTransactionFactory = operationsTransactionFactory;
            _localIdTracker          = localIdTracker;
            _resourceContextProvider = resourceContextProvider;
            _request          = request;
            _targetedFields   = targetedFields;
            _localIdValidator = new LocalIdValidator(_localIdTracker, _resourceContextProvider);
        }
Ejemplo n.º 16
0
        public RequestDeserializer(IResourceContextProvider resourceContextProvider, IResourceFactory resourceFactory, ITargetedFields targetedFields,
                                   IHttpContextAccessor httpContextAccessor, IJsonApiRequest request, IJsonApiOptions options)
            : base(resourceContextProvider, resourceFactory)
        {
            ArgumentGuard.NotNull(targetedFields, nameof(targetedFields));
            ArgumentGuard.NotNull(httpContextAccessor, nameof(httpContextAccessor));
            ArgumentGuard.NotNull(request, nameof(request));
            ArgumentGuard.NotNull(options, nameof(options));

            _targetedFields      = targetedFields;
            _httpContextAccessor = httpContextAccessor;
            _request             = request;
            _options             = options;

#pragma warning disable 612 // Method is obsolete
            _resourceDefinitionAccessor = resourceFactory.GetResourceDefinitionAccessor();
#pragma warning restore 612
        }
        public SelectClauseBuilder(Expression source, LambdaScope lambdaScope, IModel entityModel, Type extensionType, LambdaParameterNameFactory nameFactory,
                                   IResourceFactory resourceFactory, IResourceContextProvider resourceContextProvider)
            : base(lambdaScope)
        {
            ArgumentGuard.NotNull(source, nameof(source));
            ArgumentGuard.NotNull(entityModel, nameof(entityModel));
            ArgumentGuard.NotNull(extensionType, nameof(extensionType));
            ArgumentGuard.NotNull(nameFactory, nameof(nameFactory));
            ArgumentGuard.NotNull(resourceFactory, nameof(resourceFactory));
            ArgumentGuard.NotNull(resourceContextProvider, nameof(resourceContextProvider));

            _source                  = source;
            _entityModel             = entityModel;
            _extensionType           = extensionType;
            _nameFactory             = nameFactory;
            _resourceFactory         = resourceFactory;
            _resourceContextProvider = resourceContextProvider;
        }
Ejemplo n.º 18
0
        public MongoDbRepository(
            IMongoDatabase mongoDatabase,
            ITargetedFields targetedFields,
            IResourceContextProvider resourceContextProvider,
            IResourceFactory resourceFactory,
            IEnumerable <IQueryConstraintProvider> constraintProviders)
        {
            _mongoDatabase           = mongoDatabase ?? throw new ArgumentNullException(nameof(mongoDatabase));
            _targetedFields          = targetedFields ?? throw new ArgumentNullException(nameof(targetedFields));
            _resourceContextProvider = resourceContextProvider ?? throw new ArgumentNullException(nameof(resourceContextProvider));
            _resourceFactory         = resourceFactory ?? throw new ArgumentNullException(nameof(resourceFactory));
            _constraintProviders     = constraintProviders ?? throw new ArgumentNullException(nameof(constraintProviders));

            if (typeof(TId) != typeof(string))
            {
                throw new InvalidConfigurationException("MongoDB can only be used for resources with an 'Id' property of type 'string'.");
            }
        }
 public DefaultResourceService(
     IEnumerable <IQueryParameterService> queryParameters,
     IJsonApiOptions options,
     IResourceRepository <TResource, TId> repository,
     IResourceContextProvider provider,
     IResourceHookExecutor hookExecutor = null,
     ILoggerFactory loggerFactory       = null)
 {
     _includeService      = queryParameters.FirstOrDefault <IIncludeService>();
     _sparseFieldsService = queryParameters.FirstOrDefault <ISparseFieldsService>();
     _pageService         = queryParameters.FirstOrDefault <IPageService>();
     _sortService         = queryParameters.FirstOrDefault <ISortService>();
     _filterService       = queryParameters.FirstOrDefault <IFilterService>();
     _options             = options;
     _repository          = repository;
     _hookExecutor        = hookExecutor;
     _logger = loggerFactory?.CreateLogger <DefaultResourceService <TResource, TId> >();
     _currentRequestResource = provider.GetResourceContext <TResource>();
 }
Ejemplo n.º 20
0
        public QueryLayerComposer(IEnumerable <IQueryConstraintProvider> constraintProviders, IResourceContextProvider resourceContextProvider,
                                  IResourceDefinitionAccessor resourceDefinitionAccessor, IJsonApiOptions options, IPaginationContext paginationContext,
                                  ITargetedFields targetedFields)
        {
            ArgumentGuard.NotNull(constraintProviders, nameof(constraintProviders));
            ArgumentGuard.NotNull(resourceContextProvider, nameof(resourceContextProvider));
            ArgumentGuard.NotNull(resourceDefinitionAccessor, nameof(resourceDefinitionAccessor));
            ArgumentGuard.NotNull(options, nameof(options));
            ArgumentGuard.NotNull(paginationContext, nameof(paginationContext));
            ArgumentGuard.NotNull(targetedFields, nameof(targetedFields));

            _constraintProviders        = constraintProviders;
            _resourceContextProvider    = resourceContextProvider;
            _resourceDefinitionAccessor = resourceDefinitionAccessor;
            _options             = options;
            _paginationContext   = paginationContext;
            _targetedFields      = targetedFields;
            _sparseFieldSetCache = new SparseFieldSetCache(_constraintProviders, resourceDefinitionAccessor);
        }
Ejemplo n.º 21
0
        public async Task InvokeAsync(HttpContext httpContext,
                                      IControllerResourceMapping controllerResourceMapping,
                                      IJsonApiOptions options,
                                      IJsonApiRequest request,
                                      IResourceContextProvider resourceContextProvider)
        {
            ArgumentGuard.NotNull(httpContext, nameof(httpContext));
            ArgumentGuard.NotNull(controllerResourceMapping, nameof(controllerResourceMapping));
            ArgumentGuard.NotNull(options, nameof(options));
            ArgumentGuard.NotNull(request, nameof(request));
            ArgumentGuard.NotNull(resourceContextProvider, nameof(resourceContextProvider));

            var routeValues = httpContext.GetRouteData().Values;

            var primaryResourceContext = CreatePrimaryResourceContext(routeValues, controllerResourceMapping, resourceContextProvider);

            if (primaryResourceContext != null)
            {
                if (!await ValidateContentTypeHeaderAsync(HeaderConstants.MediaType, httpContext, options.SerializerSettings) ||
                    !await ValidateAcceptHeaderAsync(MediaType, httpContext, options.SerializerSettings))
                {
                    return;
                }

                SetupResourceRequest((JsonApiRequest)request, primaryResourceContext, routeValues, options, resourceContextProvider, httpContext.Request);

                httpContext.RegisterJsonApiRequest();
            }
            else if (IsOperationsRequest(routeValues))
            {
                if (!await ValidateContentTypeHeaderAsync(HeaderConstants.AtomicOperationsMediaType, httpContext, options.SerializerSettings) ||
                    !await ValidateAcceptHeaderAsync(AtomicOperationsMediaType, httpContext, options.SerializerSettings))
                {
                    return;
                }

                SetupOperationsRequest((JsonApiRequest)request, options, httpContext.Request);

                httpContext.RegisterJsonApiRequest();
            }

            await _next(httpContext);
        }
Ejemplo n.º 22
0
        private static ResourceContext CreatePrimaryResourceContext(HttpContext httpContext, IControllerResourceMapping controllerResourceMapping,
                                                                    IResourceContextProvider resourceContextProvider)
        {
            Endpoint endpoint = httpContext.GetEndpoint();
            var      controllerActionDescriptor = endpoint?.Metadata.GetMetadata <ControllerActionDescriptor>();

            if (controllerActionDescriptor != null)
            {
                Type controllerType = controllerActionDescriptor.ControllerTypeInfo;
                Type resourceType   = controllerResourceMapping.GetResourceTypeForController(controllerType);

                if (resourceType != null)
                {
                    return(resourceContextProvider.GetResourceContext(resourceType));
                }
            }

            return(null);
        }
Ejemplo n.º 23
0
        public LinkBuilder(IJsonApiOptions options, IJsonApiRequest request, IPaginationContext paginationContext,
                           IResourceContextProvider resourceContextProvider, IHttpContextAccessor httpContextAccessor, LinkGenerator linkGenerator,
                           IControllerResourceMapping controllerResourceMapping)
        {
            ArgumentGuard.NotNull(options, nameof(options));
            ArgumentGuard.NotNull(request, nameof(request));
            ArgumentGuard.NotNull(paginationContext, nameof(paginationContext));
            ArgumentGuard.NotNull(resourceContextProvider, nameof(resourceContextProvider));
            ArgumentGuard.NotNull(linkGenerator, nameof(linkGenerator));
            ArgumentGuard.NotNull(controllerResourceMapping, nameof(controllerResourceMapping));

            _options                   = options;
            _request                   = request;
            _paginationContext         = paginationContext;
            _resourceContextProvider   = resourceContextProvider;
            _httpContextAccessor       = httpContextAccessor;
            _linkGenerator             = linkGenerator;
            _controllerResourceMapping = controllerResourceMapping;
        }
Ejemplo n.º 24
0
        public QueryableBuilder(Expression source, Type elementType, Type extensionType, LambdaParameterNameFactory nameFactory,
                                IResourceFactory resourceFactory, IResourceContextProvider resourceContextProvider, IModel entityModel,
                                LambdaScopeFactory lambdaScopeFactory = null)
        {
            ArgumentGuard.NotNull(source, nameof(source));
            ArgumentGuard.NotNull(elementType, nameof(elementType));
            ArgumentGuard.NotNull(extensionType, nameof(extensionType));
            ArgumentGuard.NotNull(nameFactory, nameof(nameFactory));
            ArgumentGuard.NotNull(resourceFactory, nameof(resourceFactory));
            ArgumentGuard.NotNull(resourceContextProvider, nameof(resourceContextProvider));
            ArgumentGuard.NotNull(entityModel, nameof(entityModel));

            _source                  = source;
            _elementType             = elementType;
            _extensionType           = extensionType;
            _nameFactory             = nameFactory;
            _resourceFactory         = resourceFactory;
            _resourceContextProvider = resourceContextProvider;
            _entityModel             = entityModel;
            _lambdaScopeFactory      = lambdaScopeFactory ?? new LambdaScopeFactory(_nameFactory);
        }
 public SortQueryStringParameterReader(IJsonApiRequest request, IResourceContextProvider resourceContextProvider)
     : base(request, resourceContextProvider)
 {
     _scopeParser = new QueryStringParameterScopeParser(resourceContextProvider, FieldChainRequirements.EndsInToMany);
     _sortParser  = new SortParser(resourceContextProvider, ValidateSingleField);
 }
Ejemplo n.º 26
0
 public DefaultTypeMatchFilter(IResourceContextProvider provider)
 {
     _provider = provider;
 }
 public SelectClauseBuilder(Expression source, LambdaScope lambdaScope, IModel entityModel, Type extensionType,
                            LambdaParameterNameFactory nameFactory, IResourceFactory resourceFactory, IResourceContextProvider resourceContextProvider)
     : base(lambdaScope)
 {
     _source                  = source ?? throw new ArgumentNullException(nameof(source));
     _entityModel             = entityModel ?? throw new ArgumentNullException(nameof(entityModel));
     _extensionType           = extensionType ?? throw new ArgumentNullException(nameof(extensionType));
     _nameFactory             = nameFactory ?? throw new ArgumentNullException(nameof(nameFactory));
     _resourceFactory         = resourceFactory ?? throw new ArgumentNullException(nameof(resourceFactory));
     _resourceContextProvider = resourceContextProvider ?? throw new ArgumentNullException(nameof(resourceContextProvider));
 }
Ejemplo n.º 28
0
 protected QueryExpressionParser(IResourceContextProvider resourceContextProvider)
 {
     ChainResolver = new ResourceFieldChainResolver(resourceContextProvider);
 }
 public SparseFieldSetParser(IResourceContextProvider resourceContextProvider, Action <ResourceFieldAttribute, ResourceContext, string> validateSingleFieldCallback = null)
     : base(resourceContextProvider)
 {
     _validateSingleFieldCallback = validateSingleFieldCallback;
 }
Ejemplo n.º 30
0
        public ResponseResourceObjectBuilder(ILinkBuilder linkBuilder, IIncludedResourceObjectBuilder includedBuilder,
                                             IEnumerable <IQueryConstraintProvider> constraintProviders, IResourceContextProvider resourceContextProvider,
                                             IResourceDefinitionAccessor resourceDefinitionAccessor, IResourceObjectBuilderSettingsProvider settingsProvider,
                                             IEvaluatedIncludeCache evaluatedIncludeCache)
            : base(resourceContextProvider, settingsProvider.Get())
        {
            ArgumentGuard.NotNull(linkBuilder, nameof(linkBuilder));
            ArgumentGuard.NotNull(includedBuilder, nameof(includedBuilder));
            ArgumentGuard.NotNull(constraintProviders, nameof(constraintProviders));
            ArgumentGuard.NotNull(resourceDefinitionAccessor, nameof(resourceDefinitionAccessor));
            ArgumentGuard.NotNull(evaluatedIncludeCache, nameof(evaluatedIncludeCache));

            _linkBuilder                = linkBuilder;
            _includedBuilder            = includedBuilder;
            _resourceDefinitionAccessor = resourceDefinitionAccessor;
            _evaluatedIncludeCache      = evaluatedIncludeCache;
            _sparseFieldSetCache        = new SparseFieldSetCache(constraintProviders, resourceDefinitionAccessor);
        }