Class FieldsReader
- Namespace
 - Sitecore.AspNetCore.SDK.LayoutService.Client.Response.Model
 
- Assembly
 - Sitecore.AspNetCore.SDK.LayoutService.Client.dll
 
Implements reading of a collection of fields as a specified type.
public abstract class FieldsReader : IFieldsReader
  - Inheritance
 - 
      
      FieldsReader
 
- Implements
 
- Derived
 
- Inherited Members
 
Properties
Fields
Gets or sets the Fields associated with this instance.
public Dictionary<string, IFieldReader> Fields { get; set; }
  Property Value
Methods
HandleReadFields(Type)
Handles reading the field collection, binding to the specified type.
protected virtual object? HandleReadFields(Type type)
  Parameters
typeTypeThe type to be bound.
Returns
- object
 A new instance of the specified type, if successful.
ReadField(Type, string)
Reads a field from the collection as the specified type.
public virtual object? ReadField(Type type, string name)
  Parameters
Returns
- object
 A new instance of the specified type.
ReadField<TField>(string)
Reads a field from the collection as the specified type.
public virtual TField? ReadField<TField>(string name) where TField : IField
  Parameters
namestringThe name of the field to be read.
Returns
- TField
 A new instance of
TField.
Type Parameters
TFieldThe type of object to return.
ReadFields(Type)
Reads the collection of fields as the specified type.
public object? ReadFields(Type type)
  Parameters
typeTypeThe type of object to return.
Returns
- object
 A new instance of the specified type.
ReadFields<T>()
Reads the collection of fields as the specified type.
public virtual T? ReadFields<T>() where T : new()
  Returns
- T
 A new instance of
T.
Type Parameters
TThe type of object to return.
TryReadField(Type, string, out object?)
Attempts to read a field from the collection as the specified type.
public virtual bool TryReadField(Type type, string name, out object? instance)
  Parameters
typeTypeThe type of object to return.
namestringThe name of the field to be read.
instanceobjectA new instance of
typeif successful.
Returns
- bool
 True if successful, otherwise false.
TryReadField<TField>(string, out TField?)
Attempts to read a field from the collection as the specified type.
public virtual bool TryReadField<TField>(string name, out TField? instance) where TField : IField
  Parameters
namestringThe name of the field to be read.
instanceTFieldThe resulting instance if successful.
Returns
- bool
 True if successful, otherwise false.
Type Parameters
TFieldThe type of object to return.
TryReadFields(Type, out object?)
Attempts to read the collection of fields as the specified type.
public bool TryReadFields(Type type, out object? instance)
  Parameters
Returns
- bool
 True if successful, otherwise false.
TryReadFields<T>(out T?)
Attempts to read the collection of fields as the specified type.
public virtual bool TryReadFields<T>(out T? instance) where T : new()
  Parameters
instanceTThe resulting instance if successful.
Returns
- bool
 True if successful, otherwise false.
Type Parameters
TThe type of object to return.