---
title: "Class FieldsReader"
slug: "sitecore.layoutservice.client.response.model.fieldsreader"
abstract: ""
---
# Class FieldsReader

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

## Inheritance

System.Object

FieldsReader

[Component](https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-asp-dot-net-rendering-sdk/sitecore.layoutservice.client.response.model.component.html)

[ItemLinkField](https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-asp-dot-net-rendering-sdk/sitecore.layoutservice.client.response.model.fields.itemlinkfield.html)

[Route](https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-asp-dot-net-rendering-sdk/sitecore.layoutservice.client.response.model.route.html)

### Implements

[IFieldsReader](https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-asp-dot-net-rendering-sdk/sitecore.layoutservice.client.response.model.ifieldsreader.html)

#### **Namespace**: Sitecore.LayoutService.Client.Response.Model

##### **Assembly**: Sitecore.LayoutService.Client.Abstractions.dll

##### Syntax

```csharp
public abstract class FieldsReader : Object, IFieldsReader

```

### Constructors

#### FieldsReader()

##### Declaration

```csharp
protected FieldsReader()

```

### Properties

#### Fields

Gets or sets the Fields associated with this instance.

##### Declaration

```csharp
public Dictionary<string, IFieldReader> Fields { get; set; }

```

##### Property Value

| Type | Description |
| --- | --- |
| System.Collections.Generic.Dictionary<br><br><<br><br>System.String<br><br>,<br><br>IFieldReader<br><br>> |  |

### Methods

#### HandleReadFields(Type)

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

##### Declaration

```csharp
protected virtual object HandleReadFields(Type type)

```

##### Parameters

| Type | Name | Description |
| --- | --- | --- |
| System.Type | type | The type to be bound. |

##### Returns

| Type | Description |
| --- | --- |
| 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

```csharp
public virtual object ReadField(Type type, string name)

```

##### Parameters

| Type | Name | Description |
| --- | --- | --- |
| System.Type | type | The type of object to return. |
| System.String | name | The name of the field to be read. |

##### Returns

| Type | Description |
| --- | --- |
| System.Object | A new instance of the specified type. |

#### ReadField<TField>(String)

Reads a field from the collection as the specified type.

##### Declaration

```

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

```

##### Parameters

| Type | Name | Description |
| --- | --- | --- |
| System.String | name | The name of the field to be read. |

##### Returns

| Type | Description |
| --- | --- |
| TField | A new instance of `TField`. |

##### Type Parameters

| Name | Description |
| --- | --- |
| TField | The type of object to return. |

#### ReadFields(Type)

Reads the collection of fields as the specified type.

##### Declaration

```csharp
public object ReadFields(Type type)

```

##### Parameters

| Type | Name | Description |
| --- | --- | --- |
| System.Type | type | The type of object to return. |

##### Returns

| Type | Description |
| --- | --- |
| System.Object | A new instance of the specified type. |

#### ReadFields<T>()

Reads the collection of fields as the specified type.

##### Declaration

```

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

```

##### Returns

| Type | Description |
| --- | --- |
| T | A new instance of `T`. |

##### Type Parameters

| Name | Description |
| --- | --- |
| 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

```csharp
public virtual bool TryReadField(Type type, string name, out object instance)

```

##### Parameters

| Type | Name | Description |
| --- | --- | --- |
| System.Type | type | The type of object to return. |
| System.String | name | The name of the field to be read. |
| System.Object | instance | A new instance of `type` if successful. |

##### Returns

| Type | Description |
| --- | --- |
| 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

```

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

```

##### Parameters

| Type | Name | Description |
| --- | --- | --- |
| System.String | name | The name of the field to be read. |
| TField | instance | The resulting instance if successful. |

##### Returns

| Type | Description |
| --- | --- |
| System.Boolean | True if successful, otherwise false. |

##### Type Parameters

| Name | Description |
| --- | --- |
| TField | The type of object to return. |

#### TryReadFields(Type, out Object)

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

##### Declaration

```csharp
public bool TryReadFields(Type type, out object instance)

```

##### Parameters

| Type | Name | Description |
| --- | --- | --- |
| System.Type | type | The type of object to return. |
| System.Object | instance | A new instance of `type` if successful. |

##### Returns

| Type | Description |
| --- | --- |
| System.Boolean | True if successful, otherwise false. |

#### TryReadFields<T>(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

| Type | Name | Description |
| --- | --- | --- |
| T | instance | The resulting instance if successful. |

##### Returns

| Type | Description |
| --- | --- |
| System.Boolean | True if successful, otherwise false. |

##### Type Parameters

| Name | Description |
| --- | --- |
| T | The type of object to return. |

### Implements

[IFieldsReader](https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-asp-dot-net-rendering-sdk/sitecore.layoutservice.client.response.model.ifieldsreader.html)
