Class FieldReader

Version: 21.x

Implements reading of a Field as a specified type.

Inheritance
System.Object
FieldReader
Implements
Namespace: Sitecore.LayoutService.Client.Response.Model
Assembly: Sitecore.LayoutService.Client.Abstractions.dll
Syntax
RequestResponse
public abstract class FieldReader : Object, IFieldReader

Constructors

FieldReader()

Declaration
RequestResponse
protected FieldReader()

Methods

HandleRead(Type)

Returns an instance of the Field data as a specified type.

Declaration
RequestResponse
protected abstract object HandleRead(Type type)
Parameters
TypeNameDescription
System.Typetype

The type to read the field as.

Returns
TypeDescription
System.Object

A new instance of the specified type.

Read(Type)

Reads the current Field as the specified type. The type must implement IField.

Declaration
RequestResponse
public virtual object Read(Type type)
Parameters
TypeNameDescription
System.Typetype

The type of field to be read.

Returns
TypeDescription
System.Object

A new instance if successful.

Read<TField>()

Reads the current Field as the specified type.

Declaration
RequestResponse
public virtual TField Read<TField>()
    where TField : IField
Returns
TypeDescription
TField

A new instance of TField.

Type Parameters
NameDescription
TField

The type of Field to be read.

TryRead(Type, out IField)

Attempts to read the current Field as the specified type. The type must implement IField.

Declaration
RequestResponse
public virtual bool TryRead(Type type, out IField field)
Parameters
TypeNameDescription
System.Typetype

The type of field to be read.

IFieldfield

The resulting field.

Returns
TypeDescription
System.Boolean

True if the field could be read as the specified type, otherwise false.

TryRead<TField>(out TField)

Attempts to read the current Field as the specified type.

Declaration
RequestResponse
public virtual bool TryRead<TField>(out TField field)
    where TField : IField
Parameters
TypeNameDescription
TFieldfield

The resulting instance if successful.

Returns
TypeDescription
System.Boolean

True if the field could be read as the specified type, otherwise false.

Type Parameters
NameDescription
TField

The type of Field to be read.

Implements

Do you have some feedback for us?

If you have suggestions for improving this article,