Class FieldsReader

Version: 21.x

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

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

Constructors

FieldsReader()

Declaration
RequestResponse
protected FieldsReader()

Properties

Fields

Gets or sets the Fields associated with this instance.

Declaration
RequestResponse
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
RequestResponse
protected virtual object HandleReadFields(Type type)
Parameters
TypeNameDescription
System.Typetype

The type to be bound.

Returns
TypeDescription
System.Object

A new instance of the specified type, if successful.

ReadField(Type, String)

Reads a field from the collection as the specified type.

Declaration
RequestResponse
public virtual object ReadField(Type type, string name)
Parameters
TypeNameDescription
System.Typetype

The type of object to return.

System.Stringname

The name of the field to be read.

Returns
TypeDescription
System.Object

A new instance of the specified type.

ReadField<TField>(String)

Reads a field from the collection as the specified type.

Declaration
RequestResponse
public virtual TField ReadField<TField>(string name)
    where TField : IField, new()
Parameters
TypeNameDescription
System.Stringname

The name of the field to be read.

Returns
TypeDescription
TField

A new instance of TField.

Type Parameters
NameDescription
TField

The type of object to return.

ReadFields(Type)

Reads the collection of fields as the specified type.

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

The type of object to return.

Returns
TypeDescription
System.Object

A new instance of the specified type.

ReadFields<T>()

Reads the collection of fields as the specified type.

Declaration
RequestResponse
public virtual T ReadFields<T>()
    where T : new()
Returns
TypeDescription
T

A new instance of T.

Type Parameters
NameDescription
T

The type of object to return.

TryReadField(Type, String, out Object)

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

Declaration
RequestResponse
public virtual bool TryReadField(Type type, string name, out object instance)
Parameters
TypeNameDescription
System.Typetype

The type of object to return.

System.Stringname

The name of the field to be read.

System.Objectinstance

A new instance of type if successful.

Returns
TypeDescription
System.Boolean

True if successful, otherwise false.

TryReadField<TField>(String, out TField)

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

Declaration
RequestResponse
public virtual bool TryReadField<TField>(string name, out TField instance)
    where TField : IField, new()
Parameters
TypeNameDescription
System.Stringname

The name of the field to be read.

TFieldinstance

The resulting instance if successful.

Returns
TypeDescription
System.Boolean

True if successful, otherwise false.

Type Parameters
NameDescription
TField

The type of object to return.

TryReadFields(Type, out Object)

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

Declaration
RequestResponse
public bool TryReadFields(Type type, out object instance)
Parameters
TypeNameDescription
System.Typetype

The type of object to return.

System.Objectinstance

A new instance of type if successful.

Returns
TypeDescription
System.Boolean

True if successful, otherwise false.

TryReadFields<T>(out T)

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

Declaration
RequestResponse
public virtual bool TryReadFields<T>(out T instance)
    where T : new()
Parameters
TypeNameDescription
Tinstance

The resulting instance if successful.

Returns
TypeDescription
System.Boolean

True if successful, otherwise false.

Type Parameters
NameDescription
T

The type of object to return.

Implements

Do you have some feedback for us?

If you have suggestions for improving this article,