using System.Runtime.Serialization;
using Umbraco.Extensions;
namespace Umbraco.Cms.Core.PropertyEditors;
///
/// Represents a datatype configuration field for editing.
///
[DataContract]
public class ConfigurationField
{
private readonly string? _view;
///
/// Initializes a new instance of the class.
///
public ConfigurationField()
: this(new List())
{
}
///
/// Initializes a new instance of the class.
///
public ConfigurationField(params IValueValidator[] validators)
: this(validators.ToList())
{
}
///
/// Initializes a new instance of the class.
///
private ConfigurationField(List validators)
{
Validators = validators;
Config = new Dictionary();
// fill details from attribute, if any
ConfigurationFieldAttribute? attribute = GetType().GetCustomAttribute(false);
if (attribute is null)
{
return;
}
Key = attribute.Key;
}
///
/// Gets or sets the key of the field.
///
[DataMember(Name = "key", IsRequired = true)]
public string Key { get; set; } = null!;
///
/// Gets or sets the property name of the field.
///
public string? PropertyName { get; set; }
///
/// Gets or sets the property CLR type of the field.
///
public Type? PropertyType { get; set; }
///
/// Gets the validators of the field.
///
[DataMember(Name = "validation")]
public List Validators { get; }
///
/// Gets or sets extra configuration properties for the editor.
///
[DataMember(Name = "config")]
public IDictionary Config { get; set; }
}