Class BlockEditorDataConverter<TValue, TLayout>
Converts the block JSON data into objects.
Inheritance
Namespace: Umbraco.Cms.Core.Models.Blocks
Assembly: Umbraco.Core.dll
Syntax
public abstract class BlockEditorDataConverter<TValue, TLayout> where TValue : BlockValue<TLayout>, new() where TLayout : IBlockLayoutItem
Type Parameters
| Name | Description |
|---|---|
| TValue | The type of the block value. |
| TLayout | The type of the layout item. |
Constructors
View SourceBlockEditorDataConverter(IJsonSerializer)
Initializes a new instance of the BlockEditorDataConverter<TValue, TLayout> class.
Declaration
protected BlockEditorDataConverter(IJsonSerializer jsonSerializer)
Parameters
| Type | Name | Description |
|---|---|---|
| IJsonSerializer | jsonSerializer | The JSON serializer. |
Methods
View SourceConvert(TValue?)
Converts the specified block value into block editor data.
Declaration
public BlockEditorData<TValue, TLayout> Convert(TValue? value)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The block value to convert. |
Returns
| Type | Description |
|---|---|
| BlockEditorData<TValue, TLayout> | The converted block editor data. |
Deserialize(string)
Deserializes the specified JSON into block editor data.
Declaration
public BlockEditorData<TValue, TLayout> Deserialize(string json)
Parameters
| Type | Name | Description |
|---|---|---|
| string | json | The JSON string to deserialize. |
Returns
| Type | Description |
|---|---|
| BlockEditorData<TValue, TLayout> | The deserialized block editor data. |
GetBlockReferences(IEnumerable<TLayout>)
Return the collection of IBlockReference from the block editor's Layout
Declaration
protected abstract IEnumerable<ContentAndSettingsReference> GetBlockReferences(IEnumerable<TLayout> layout)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<TLayout> | layout |
Returns
| Type | Description |
|---|---|
| IEnumerable<ContentAndSettingsReference> |
TryDeserialize(string, out BlockEditorData<TValue, TLayout>)
Tries to deserialize the specified JSON into block editor data.
Declaration
public bool TryDeserialize(string json, out BlockEditorData<TValue, TLayout> blockEditorData)
Parameters
| Type | Name | Description |
|---|---|---|
| string | json | The JSON string to deserialize. |
| BlockEditorData<TValue, TLayout> | blockEditorData | When this method returns, contains the block editor data if deserialization succeeded, or null if it failed. |
Returns
| Type | Description |
|---|---|
| bool |
|