Files
Umbraco-CMS/src/Umbraco.Core/PropertyEditors/IntegerPropertyEditor.cs
Kenn Jacobsen 147c60f04b Performance improvement: Reusable data editors (#12921)
* Introduce opt-in option for reusable data editors

* Verified RTE as reusable

* Make attribute property naming more explicit + update comments

* Test file upload and image cropper

* Add unit tests

(cherry picked from commit 44122c6509)
2022-09-19 16:16:03 +02:00

34 lines
1.0 KiB
C#

using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.PropertyEditors.Validators;
namespace Umbraco.Cms.Core.PropertyEditors;
/// <summary>
/// Represents an integer property and parameter editor.
/// </summary>
[DataEditor(
Constants.PropertyEditors.Aliases.Integer,
EditorType.PropertyValue | EditorType.MacroParameter,
"Numeric",
"integer",
ValueType = ValueTypes.Integer,
ValueEditorIsReusable = true)]
public class IntegerPropertyEditor : DataEditor
{
public IntegerPropertyEditor(
IDataValueEditorFactory dataValueEditorFactory)
: base(dataValueEditorFactory) =>
SupportsReadOnly = true;
/// <inheritdoc />
protected override IDataValueEditor CreateValueEditor()
{
IDataValueEditor editor = base.CreateValueEditor();
editor.Validators.Add(new IntegerValidator()); // ensure the value is validated
return editor;
}
/// <inheritdoc />
protected override IConfigurationEditor CreateConfigurationEditor() => new IntegerConfigurationEditor();
}