Class FieldsReader

Version: 21.x

Implements reading of a collection of fields as a specified type.

Inheritance

System.Object

FieldsReader

Component

ItemLinkField

Route

Implements

IFieldsReader

Namespace: Sitecore.LayoutService.Client.Response.Model

Assembly: Sitecore.LayoutService.Client.Abstractions.dll
Syntax
public abstract class FieldsReader : Object, IFieldsReader

Constructors

FieldsReader()

Declaration
protected FieldsReader()

Properties

Fields

Gets or sets the Fields associated with this instance.

Declaration
public Dictionary<string, IFieldReader> Fields { get; set; }
Property Value
TypeDescription
System.Collections.Generic.Dictionary

<

System.String

,

IFieldReader

>

Methods

HandleReadFields(Type)

Handles reading the field collection, binding to the specified type.

Declaration
protected virtual object HandleReadFields(Type type)
Parameters
TypeNameDescription
System.TypetypeThe type to be bound.
Returns
TypeDescription
System.ObjectA new instance of the specified type, if successful.

ReadField(Type, String)

Reads a field from the collection as the specified type.

Declaration
public virtual object ReadField(Type type, string name)
Parameters
TypeNameDescription
System.TypetypeThe type of object to return.
System.StringnameThe name of the field to be read.
Returns
TypeDescription
System.ObjectA new instance of the specified type.

ReadField(String)

Reads a field from the collection as the specified type.

Declaration

public virtual TField ReadField<TField>(string name)
    where TField : IField, new()

Parameters
TypeNameDescription
System.StringnameThe name of the field to be read.
Returns
TypeDescription
TFieldA new instance of TField.
Type Parameters
NameDescription
TFieldThe type of object to return.

ReadFields(Type)

Reads the collection of fields as the specified type.

Declaration
public object ReadFields(Type type)
Parameters
TypeNameDescription
System.TypetypeThe type of object to return.
Returns
TypeDescription
System.ObjectA new instance of the specified type.

ReadFields()

Reads the collection of fields as the specified type.

Declaration

public virtual T ReadFields<T>()
    where T : new()

Returns
TypeDescription
TA new instance of T.
Type Parameters
NameDescription
TThe type of object to return.

TryReadField(Type, String, out Object)

Attempts to read a field from the collection as the specified type.

Declaration
public virtual bool TryReadField(Type type, string name, out object instance)
Parameters
TypeNameDescription
System.TypetypeThe type of object to return.
System.StringnameThe name of the field to be read.
System.ObjectinstanceA new instance of type if successful.
Returns
TypeDescription
System.BooleanTrue if successful, otherwise false.

TryReadField(String, out TField)

Attempts to read a field from the collection as the specified type.

Declaration

public virtual bool TryReadField<TField>(string name, out TField instance)
    where TField : IField, new()

Parameters
TypeNameDescription
System.StringnameThe name of the field to be read.
TFieldinstanceThe resulting instance if successful.
Returns
TypeDescription
System.BooleanTrue if successful, otherwise false.
Type Parameters
NameDescription
TFieldThe type of object to return.

TryReadFields(Type, out Object)

Attempts to read the collection of fields as the specified type.

Declaration
public bool TryReadFields(Type type, out object instance)
Parameters
TypeNameDescription
System.TypetypeThe type of object to return.
System.ObjectinstanceA new instance of type if successful.
Returns
TypeDescription
System.BooleanTrue if successful, otherwise false.

TryReadFields(out T)

Attempts to read the collection of fields as the specified type.

Declaration

public virtual bool TryReadFields<T>(out T instance)
    where T : new()

Parameters
TypeNameDescription
TinstanceThe resulting instance if successful.
Returns
TypeDescription
System.BooleanTrue if successful, otherwise false.
Type Parameters
NameDescription
TThe type of object to return.

Implements

IFieldsReader

If you have suggestions for improving this article, let us know!