Headless CMS and Content Managment Hub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

68 lines
1.9 KiB

// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System.Diagnostics;
using Jint.Native;
using Squidex.Infrastructure.Json.Objects;
namespace Squidex.Domain.Apps.Core.Scripting.ContentWrapper
{
public sealed class ContentFieldProperty : CustomProperty
{
private readonly ContentFieldObject contentField;
private JsonValue contentValue;
private JsValue? value;
private bool isChanged;
[DebuggerHidden]
protected override JsValue? CustomValue
{
get
{
if (value == null)
{
if (contentValue != default)
{
value = JsonMapper.Map(contentValue, contentField.Engine);
}
}
return value;
}
set
{
var newContentValue = JsonMapper.Map(value);
if (!Equals(contentValue, newContentValue))
{
this.value = value;
contentValue = newContentValue;
contentField.MarkChanged();
isChanged = true;
}
}
}
public JsonValue ContentValue
{
get => contentValue;
}
public bool IsChanged
{
get => isChanged;
}
public ContentFieldProperty(ContentFieldObject contentField, JsonValue contentValue = default)
{
this.contentField = contentField;
this.contentValue = contentValue;
}
}
}