Class ResourceType
- Namespace
- JsonApiDotNetCore.Configuration
- Assembly
- JsonApiDotNetCore.Annotations.dll
Metadata about the shape of a JSON:API resource in the resource graph.
[PublicAPI]
public sealed class ResourceType
- Inheritance
-
ResourceType
- Inherited Members
Constructors
ResourceType(string, ClientIdGenerationMode?, Type, Type, LinkTypes, LinkTypes, LinkTypes)
public ResourceType(string publicName, ClientIdGenerationMode? clientIdGeneration, Type clrType, Type identityClrType, LinkTypes topLevelLinks = LinkTypes.NotConfigured, LinkTypes resourceLinks = LinkTypes.NotConfigured, LinkTypes relationshipLinks = LinkTypes.NotConfigured)
Parameters
publicName
stringclientIdGeneration
ClientIdGenerationMode?clrType
TypeidentityClrType
TypetopLevelLinks
LinkTypesresourceLinks
LinkTypesrelationshipLinks
LinkTypes
ResourceType(string, ClientIdGenerationMode?, Type, Type, IReadOnlyCollection<AttrAttribute>?, IReadOnlyCollection<RelationshipAttribute>?, IReadOnlyCollection<EagerLoadAttribute>?, LinkTypes, LinkTypes, LinkTypes)
public ResourceType(string publicName, ClientIdGenerationMode? clientIdGeneration, Type clrType, Type identityClrType, IReadOnlyCollection<AttrAttribute>? attributes, IReadOnlyCollection<RelationshipAttribute>? relationships, IReadOnlyCollection<EagerLoadAttribute>? eagerLoads, LinkTypes topLevelLinks = LinkTypes.NotConfigured, LinkTypes resourceLinks = LinkTypes.NotConfigured, LinkTypes relationshipLinks = LinkTypes.NotConfigured)
Parameters
publicName
stringclientIdGeneration
ClientIdGenerationMode?clrType
TypeidentityClrType
Typeattributes
IReadOnlyCollection<AttrAttribute>relationships
IReadOnlyCollection<RelationshipAttribute>eagerLoads
IReadOnlyCollection<EagerLoadAttribute>topLevelLinks
LinkTypesresourceLinks
LinkTypesrelationshipLinks
LinkTypes
Properties
Attributes
Exposed resource attributes. See https://jsonapi.org/format/#document-resource-object-attributes. When using resource inheritance, this includes the attributes from base types.
public IReadOnlyCollection<AttrAttribute> Attributes { get; }
Property Value
BaseType
The base resource type, in case this is a derived type.
public ResourceType? BaseType { get; }
Property Value
ClientIdGeneration
Whether API clients are allowed or required to provide IDs when creating resources of this type. When null
, the value from global options
applies.
public ClientIdGenerationMode? ClientIdGeneration { get; }
Property Value
ClrType
The CLR type of the resource.
public Type ClrType { get; }
Property Value
DirectlyDerivedTypes
The resource types that directly derive from this one.
public IReadOnlySet<ResourceType> DirectlyDerivedTypes { get; }
Property Value
EagerLoads
Related entities that are not exposed as resource relationships. When using resource inheritance, this includes the eager-loads from base types.
public IReadOnlyCollection<EagerLoadAttribute> EagerLoads { get; }
Property Value
Fields
Exposed resource attributes and relationships. See https://jsonapi.org/format/#document-resource-object-fields. When using resource inheritance, this includes the attributes and relationships from base types.
public IReadOnlyCollection<ResourceFieldAttribute> Fields { get; }
Property Value
IdentityClrType
The CLR type of the resource identity.
public Type IdentityClrType { get; }
Property Value
PublicName
The publicly exposed resource name.
public string PublicName { get; }
Property Value
RelationshipLinks
Configures which links to write in the relationship-level links object for all relationships of this resource type. Defaults to NotConfigured, which falls back to RelationshipLinks in global options. This can be overruled per relationship by setting Links.
public LinkTypes RelationshipLinks { get; }
Property Value
Remarks
In the process of building the resource graph, this value is set based on RelationshipLinks usage.
Relationships
Exposed resource relationships. See https://jsonapi.org/format/#document-resource-object-relationships. When using resource inheritance, this includes the relationships from base types.
public IReadOnlyCollection<RelationshipAttribute> Relationships { get; }
Property Value
ResourceLinks
Configures which links to write in the resource-level links object for this resource type. Defaults to NotConfigured, which falls back to ResourceLinks in global options.
public LinkTypes ResourceLinks { get; }
Property Value
Remarks
In the process of building the resource graph, this value is set based on ResourceLinks usage.
TopLevelLinks
Configures which links to write in the top-level links object for this resource type. Defaults to NotConfigured, which falls back to TopLevelLinks in global options.
public LinkTypes TopLevelLinks { get; }
Property Value
Remarks
In the process of building the resource graph, this value is set based on TopLevelLinks usage.
Methods
Equals(object?)
Determines whether the specified object is equal to the current object.
public override bool Equals(object? obj)
Parameters
obj
objectThe object to compare with the current object.
Returns
FindAttributeByPropertyName(string)
public AttrAttribute? FindAttributeByPropertyName(string propertyName)
Parameters
propertyName
string
Returns
FindAttributeByPublicName(string)
public AttrAttribute? FindAttributeByPublicName(string publicName)
Parameters
publicName
string
Returns
FindRelationshipByPropertyName(string)
public RelationshipAttribute? FindRelationshipByPropertyName(string propertyName)
Parameters
propertyName
string
Returns
FindRelationshipByPublicName(string)
public RelationshipAttribute? FindRelationshipByPublicName(string publicName)
Parameters
publicName
string
Returns
GetAllConcreteDerivedTypes()
Returns all directly and indirectly non-abstract resource types that derive from this resource type.
public IReadOnlySet<ResourceType> GetAllConcreteDerivedTypes()
Returns
GetAttributeByPropertyName(string)
public AttrAttribute GetAttributeByPropertyName(string propertyName)
Parameters
propertyName
string
Returns
GetAttributeByPublicName(string)
public AttrAttribute GetAttributeByPublicName(string publicName)
Parameters
publicName
string
Returns
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
GetRelationshipByPropertyName(string)
public RelationshipAttribute GetRelationshipByPropertyName(string propertyName)
Parameters
propertyName
string
Returns
GetRelationshipByPublicName(string)
public RelationshipAttribute GetRelationshipByPublicName(string publicName)
Parameters
publicName
string
Returns
GetTypeOrDerived(Type)
Searches the tree of derived types to find a match for the specified clrType
.
public ResourceType GetTypeOrDerived(Type clrType)
Parameters
clrType
Type
Returns
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.