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
type
TypeThe 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
name
stringThe name of the field to be read.
Returns
- TField
A new instance of
TField
.
Type Parameters
TField
The type of object to return.
ReadFields(Type)
Reads the collection of fields as the specified type.
public object? ReadFields(Type type)
Parameters
type
TypeThe 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
T
The 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
type
TypeThe type of object to return.
name
stringThe name of the field to be read.
instance
objectA new instance of
type
if 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
name
stringThe name of the field to be read.
instance
TFieldThe resulting instance if successful.
Returns
- bool
True if successful, otherwise false.
Type Parameters
TField
The 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
instance
TThe resulting instance if successful.
Returns
- bool
True if successful, otherwise false.
Type Parameters
T
The type of object to return.