Gets copying logic working for the block editor, needs more tests though
This commit is contained in:
@@ -18,10 +18,35 @@ namespace Umbraco.Core.Models.Blocks
|
||||
_propertyEditorAlias = propertyEditorAlias;
|
||||
}
|
||||
|
||||
public BlockEditorData ConvertFrom(JToken json)
|
||||
{
|
||||
var value = json.ToObject<BlockValue>();
|
||||
return Convert(value);
|
||||
}
|
||||
|
||||
public bool TryDeserialize(string json, out BlockEditorData blockEditorData)
|
||||
{
|
||||
try
|
||||
{
|
||||
var value = JsonConvert.DeserializeObject<BlockValue>(json);
|
||||
blockEditorData = Convert(value);
|
||||
return true;
|
||||
}
|
||||
catch (System.Exception)
|
||||
{
|
||||
blockEditorData = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public BlockEditorData Deserialize(string json)
|
||||
{
|
||||
var value = JsonConvert.DeserializeObject<BlockValue>(json);
|
||||
return Convert(value);
|
||||
}
|
||||
|
||||
private BlockEditorData Convert(BlockValue value)
|
||||
{
|
||||
if (value.Layout == null)
|
||||
return BlockEditorData.Empty;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Umbraco.Core.Models.Blocks
|
||||
[JsonConverter(typeof(UdiJsonConverter))]
|
||||
public Udi ContentUdi { get; set; }
|
||||
|
||||
[JsonProperty("settingsUdi")]
|
||||
[JsonProperty("settingsUdi", NullValueHandling = NullValueHandling.Ignore)]
|
||||
[JsonConverter(typeof(UdiJsonConverter))]
|
||||
public Udi SettingsUdi { get; set; }
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Runtime.Serialization;
|
||||
|
||||
namespace Umbraco.Core.Models
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of property values.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user