Class ContentListField<TTargetModel>
- Namespace
- Sitecore.AspNetCore.SDK.LayoutService.Client.Response.Model.Fields
- Assembly
- Sitecore.AspNetCore.SDK.LayoutService.Client.dll
Allows list field types to be mapped to a specific model.
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1649:File name should match first type name", Justification = "Generic Type.")]
public class ContentListField<TTargetModel> : List<ItemLinkField<TTargetModel>>, IList<ItemLinkField<TTargetModel>>, ICollection<ItemLinkField<TTargetModel>>, IReadOnlyList<ItemLinkField<TTargetModel>>, IReadOnlyCollection<ItemLinkField<TTargetModel>>, IEnumerable<ItemLinkField<TTargetModel>>, IList, ICollection, IEnumerable, IField, IFieldReader where TTargetModel : class
Type Parameters
TTargetModelStrongly typed model to map the target of each list item to.
- Inheritance
-
List<ItemLinkField<TTargetModel>>ContentListField<TTargetModel>
- Implements
-
IList<ItemLinkField<TTargetModel>>ICollection<ItemLinkField<TTargetModel>>IReadOnlyList<ItemLinkField<TTargetModel>>IReadOnlyCollection<ItemLinkField<TTargetModel>>IEnumerable<ItemLinkField<TTargetModel>>
- Inherited Members
Methods
HandleRead(Type)
Returns an instance of the Field data as a specified type.
protected virtual object HandleRead(Type type)
Parameters
typeTypeThe type to read the field as.
Returns
- object
A new instance of the specified type.
Read(Type)
Reads the current Field as the specified type. The type must implement IField.
public virtual object Read(Type type)
Parameters
typeTypeThe type of field to be read.
Returns
- object
A new instance if successful.
Read<TField>()
Reads the current Field as the specified type.
public virtual TField Read<TField>() where TField : IField
Returns
- TField
A new instance of
TField.
Type Parameters
TFieldThe 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.
public virtual bool TryRead(Type type, out IField? field)
Parameters
Returns
- bool
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.
public virtual bool TryRead<TField>(out TField? field) where TField : IField
Parameters
fieldTFieldThe resulting instance if successful.
Returns
- bool
True if the field could be read as the specified type, otherwise false.
Type Parameters
TFieldThe type of Field to be read.