Gets copying logic working for the block editor, needs more tests though

This commit is contained in:
Shannon
2020-09-08 02:07:02 +10:00
parent 40d13bfb2f
commit a2c24bcc76
14 changed files with 511 additions and 49 deletions

View File

@@ -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;

View File

@@ -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; }
}

View File

@@ -7,6 +7,7 @@ using System.Runtime.Serialization;
namespace Umbraco.Core.Models
{
/// <summary>
/// Represents a collection of property values.
/// </summary>