Class ResourceFieldAttribute
- Namespace
- JsonApiDotNetCore.Resources.Annotations
- Assembly
- JsonApiDotNetCore.Annotations.dll
Used to expose a property on a resource class as a JSON:API field (attribute or relationship). See https://jsonapi.org/format/#document-resource-object-fields.
[PublicAPI]
public abstract class ResourceFieldAttribute : Attribute- Inheritance
- 
      
      
      ResourceFieldAttribute
- Derived
- Inherited Members
Properties
Property
The resource property that this attribute is declared on.
public PropertyInfo Property { get; }Property Value
PublicName
The publicly exposed name of this JSON:API field. When not explicitly set, the configured naming convention is applied on the property name.
public string PublicName { get; set; }Property Value
Type
The containing resource type in which this field is declared.
public ResourceType Type { get; }Property Value
Methods
AssertIsIdentifiable(object?)
protected void AssertIsIdentifiable(object? resource)Parameters
- resourceobject
Equals(object?)
Returns a value that indicates whether this instance is equal to a specified object.
public override bool Equals(object? obj)Parameters
Returns
- bool
- true if - objand this instance are of the same type and have identical field values; otherwise, false.
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()Returns
- int
- A 32-bit signed integer hash code. 
GetValue(object)
Gets the value of this field on the specified resource instance. Throws if the property is write-only or if the field does not belong to the specified resource instance.
public object? GetValue(object resource)Parameters
- resourceobject
Returns
SetValue(object, object?)
Sets the value of this field on the specified resource instance. Throws if the property is read-only or if the field does not belong to the specified resource instance.
public virtual void SetValue(object resource, object? newValue)Parameters
ToFullString()
public string ToFullString()Returns
ToString()
Returns a string that represents the current object.
public override string? ToString()Returns
- string
- A string that represents the current object.