Table of Contents

Class ResourceDefinitionAccessor

Namespace
JsonApiDotNetCore.Resources
Assembly
JsonApiDotNetCore.dll

Retrieves an IResourceDefinition<TResource, TId> instance from the D/I container and invokes a callback on it.

[PublicAPI]
public class ResourceDefinitionAccessor : IResourceDefinitionAccessor
Inheritance
ResourceDefinitionAccessor
Implements
Inherited Members

Constructors

ResourceDefinitionAccessor(IResourceGraph, IServiceProvider)

public ResourceDefinitionAccessor(IResourceGraph resourceGraph, IServiceProvider serviceProvider)

Parameters

resourceGraph IResourceGraph
serviceProvider IServiceProvider

Properties

IsReadOnlyRequest

Indicates whether this request targets only fetching of data (resources and relationships), as opposed to applying changes.

[Obsolete("Use IJsonApiRequest.IsReadOnly.")]
public bool IsReadOnlyRequest { get; }

Property Value

bool

Remarks

This property was added to reduce the impact of taking a breaking change. It will likely be removed in the next major version.

QueryableBuilder

Gets an IQueryableBuilder instance from the service container.

[Obsolete("Use injected IQueryableBuilder instead.")]
public IQueryableBuilder QueryableBuilder { get; }

Property Value

IQueryableBuilder

Remarks

This property was added to reduce the impact of taking a breaking change. It will likely be removed in the next major version.

Methods

GetMeta(ResourceType, IIdentifiable)

Invokes GetMeta(TResource) for the specified resource.

public IDictionary<string, object?>? GetMeta(ResourceType resourceType, IIdentifiable resourceInstance)

Parameters

resourceType ResourceType
resourceInstance IIdentifiable

Returns

IDictionary<string, object>

GetQueryableHandlerForQueryStringParameter(Type, string)

Invokes OnRegisterQueryableHandlersForQueryStringParameters() for the specified resource type, then returns the IQueryable<T> expression for the specified parameter name.

public object? GetQueryableHandlerForQueryStringParameter(Type resourceClrType, string parameterName)

Parameters

resourceClrType Type
parameterName string

Returns

object

OnAddToRelationshipAsync<TResource>(TResource, HasManyAttribute, ISet<IIdentifiable>, CancellationToken)

public Task OnAddToRelationshipAsync<TResource>(TResource leftResource, HasManyAttribute hasManyRelationship, ISet<IIdentifiable> rightResourceIds, CancellationToken cancellationToken) where TResource : class, IIdentifiable

Parameters

leftResource TResource
hasManyRelationship HasManyAttribute
rightResourceIds ISet<IIdentifiable>
cancellationToken CancellationToken

Returns

Task

Type Parameters

TResource

OnApplyFilter(ResourceType, FilterExpression?)

Invokes OnApplyFilter(FilterExpression?) for the specified resource type.

public FilterExpression? OnApplyFilter(ResourceType resourceType, FilterExpression? existingFilter)

Parameters

resourceType ResourceType
existingFilter FilterExpression

Returns

FilterExpression

OnApplyIncludes(ResourceType, IImmutableSet<IncludeElementExpression>)

Invokes OnApplyIncludes(IImmutableSet<IncludeElementExpression>) for the specified resource type.

public IImmutableSet<IncludeElementExpression> OnApplyIncludes(ResourceType resourceType, IImmutableSet<IncludeElementExpression> existingIncludes)

Parameters

resourceType ResourceType
existingIncludes IImmutableSet<IncludeElementExpression>

Returns

IImmutableSet<IncludeElementExpression>

OnApplyPagination(ResourceType, PaginationExpression?)

Invokes OnApplyPagination(PaginationExpression?) for the specified resource type.

public PaginationExpression? OnApplyPagination(ResourceType resourceType, PaginationExpression? existingPagination)

Parameters

resourceType ResourceType
existingPagination PaginationExpression

Returns

PaginationExpression

OnApplySort(ResourceType, SortExpression?)

Invokes OnApplySort(SortExpression?) for the specified resource type.

public SortExpression? OnApplySort(ResourceType resourceType, SortExpression? existingSort)

Parameters

resourceType ResourceType
existingSort SortExpression

Returns

SortExpression

OnApplySparseFieldSet(ResourceType, SparseFieldSetExpression?)

Invokes OnApplySparseFieldSet(SparseFieldSetExpression?) for the specified resource type.

public SparseFieldSetExpression? OnApplySparseFieldSet(ResourceType resourceType, SparseFieldSetExpression? existingSparseFieldSet)

Parameters

resourceType ResourceType
existingSparseFieldSet SparseFieldSetExpression

Returns

SparseFieldSetExpression

OnDeserialize(IIdentifiable)

Invokes OnDeserialize(TResource) for the specified resource.

public void OnDeserialize(IIdentifiable resource)

Parameters

resource IIdentifiable

OnPrepareWriteAsync<TResource>(TResource, WriteOperationKind, CancellationToken)

public Task OnPrepareWriteAsync<TResource>(TResource resource, WriteOperationKind writeOperation, CancellationToken cancellationToken) where TResource : class, IIdentifiable

Parameters

resource TResource
writeOperation WriteOperationKind
cancellationToken CancellationToken

Returns

Task

Type Parameters

TResource

OnRemoveFromRelationshipAsync<TResource>(TResource, HasManyAttribute, ISet<IIdentifiable>, CancellationToken)

public Task OnRemoveFromRelationshipAsync<TResource>(TResource leftResource, HasManyAttribute hasManyRelationship, ISet<IIdentifiable> rightResourceIds, CancellationToken cancellationToken) where TResource : class, IIdentifiable

Parameters

leftResource TResource
hasManyRelationship HasManyAttribute
rightResourceIds ISet<IIdentifiable>
cancellationToken CancellationToken

Returns

Task

Type Parameters

TResource

OnSerialize(IIdentifiable)

Invokes OnSerialize(TResource) for the specified resource.

public void OnSerialize(IIdentifiable resource)

Parameters

resource IIdentifiable

OnSetToManyRelationshipAsync<TResource>(TResource, HasManyAttribute, ISet<IIdentifiable>, WriteOperationKind, CancellationToken)

public Task OnSetToManyRelationshipAsync<TResource>(TResource leftResource, HasManyAttribute hasManyRelationship, ISet<IIdentifiable> rightResourceIds, WriteOperationKind writeOperation, CancellationToken cancellationToken) where TResource : class, IIdentifiable

Parameters

leftResource TResource
hasManyRelationship HasManyAttribute
rightResourceIds ISet<IIdentifiable>
writeOperation WriteOperationKind
cancellationToken CancellationToken

Returns

Task

Type Parameters

TResource

OnSetToOneRelationshipAsync<TResource>(TResource, HasOneAttribute, IIdentifiable?, WriteOperationKind, CancellationToken)

public Task<IIdentifiable?> OnSetToOneRelationshipAsync<TResource>(TResource leftResource, HasOneAttribute hasOneRelationship, IIdentifiable? rightResourceId, WriteOperationKind writeOperation, CancellationToken cancellationToken) where TResource : class, IIdentifiable

Parameters

leftResource TResource
hasOneRelationship HasOneAttribute
rightResourceId IIdentifiable
writeOperation WriteOperationKind
cancellationToken CancellationToken

Returns

Task<IIdentifiable>

Type Parameters

TResource

OnWriteSucceededAsync<TResource>(TResource, WriteOperationKind, CancellationToken)

public Task OnWriteSucceededAsync<TResource>(TResource resource, WriteOperationKind writeOperation, CancellationToken cancellationToken) where TResource : class, IIdentifiable

Parameters

resource TResource
writeOperation WriteOperationKind
cancellationToken CancellationToken

Returns

Task

Type Parameters

TResource

OnWritingAsync<TResource>(TResource, WriteOperationKind, CancellationToken)

public Task OnWritingAsync<TResource>(TResource resource, WriteOperationKind writeOperation, CancellationToken cancellationToken) where TResource : class, IIdentifiable

Parameters

resource TResource
writeOperation WriteOperationKind
cancellationToken CancellationToken

Returns

Task

Type Parameters

TResource

ResolveResourceDefinition(ResourceType)

protected virtual object ResolveResourceDefinition(ResourceType resourceType)

Parameters

resourceType ResourceType

Returns

object

ResolveResourceDefinition(Type)

protected object ResolveResourceDefinition(Type resourceClrType)

Parameters

resourceClrType Type

Returns

object