Files
Umbraco-CMS/src/Umbraco.Core/PropertyEditors/LabelPropertyEditor.cs
Nikolaj Geisle f23b57db65 V10: fix more nullable references (#12321)
* Add Nullable and WarningsAsErrors to Build.props

* Remove Nullable from cs proj, add ImplicitUsings to build.props

* Fix errors in core

* Fix in JsonSchema

* Fix infrastructure

* Add non-ambiguous using

* Fix Web/Lucene

* Fix backoffice

* Fix up new build errors from merge

Co-authored-by: Nikolaj Geisle <niko737@edu.ucl.dk>
2022-04-29 15:02:36 +02:00

71 lines
2.6 KiB
C#

// Copyright (c) Umbraco.
// See LICENSE for more details.
using System;
using Microsoft.Extensions.DependencyInjection;
using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Serialization;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Strings;
using Umbraco.Cms.Web.Common.DependencyInjection;
namespace Umbraco.Cms.Core.PropertyEditors
{
/// <summary>
/// Represents a property editor for label properties.
/// </summary>
[DataEditor(
Cms.Core.Constants.PropertyEditors.Aliases.Label,
"Label",
"readonlyvalue",
Icon = "icon-readonly")]
public class LabelPropertyEditor : DataEditor
{
private readonly IIOHelper _ioHelper;
private readonly IEditorConfigurationParser _editorConfigurationParser;
// Scheduled for removal in v12
[Obsolete("Please use constructor that takes an IEditorConfigurationParser instead")]
public LabelPropertyEditor(IDataValueEditorFactory dataValueEditorFactory,
IIOHelper ioHelper)
: this(dataValueEditorFactory, ioHelper, StaticServiceProvider.Instance.GetRequiredService<IEditorConfigurationParser>())
{
}
/// <summary>
/// Initializes a new instance of the <see cref="LabelPropertyEditor"/> class.
/// </summary>
public LabelPropertyEditor(IDataValueEditorFactory dataValueEditorFactory,
IIOHelper ioHelper,
IEditorConfigurationParser editorConfigurationParser)
: base(dataValueEditorFactory)
{
_ioHelper = ioHelper;
_editorConfigurationParser = editorConfigurationParser;
}
/// <inheritdoc />
protected override IDataValueEditor CreateValueEditor() => DataValueEditorFactory.Create<LabelPropertyValueEditor>(Attribute!);
/// <inheritdoc />
protected override IConfigurationEditor CreateConfigurationEditor() => new LabelConfigurationEditor(_ioHelper, _editorConfigurationParser);
// provides the property value editor
internal class LabelPropertyValueEditor : DataValueEditor
{
public LabelPropertyValueEditor(
ILocalizedTextService localizedTextService,
IShortStringHelper shortStringHelper,
IJsonSerializer jsonSerializer,
IIOHelper ioHelper,
DataEditorAttribute attribute)
: base(localizedTextService, shortStringHelper, jsonSerializer, ioHelper, attribute)
{ }
/// <inheritdoc />
public override bool IsReadOnly => true;
}
}
}