Class ConfigurationEditor
Represents a data type configuration editor.
Inheritance
Namespace: Umbraco.Cms.Core.PropertyEditors
Assembly: Umbraco.Core.dll
Syntax
[DataContract]
public class ConfigurationEditor : IConfigurationEditor
Constructors
View SourceConfigurationEditor()
Initializes a new instance of the ConfigurationEditor class.
Declaration
public ConfigurationEditor()
ConfigurationEditor(List<ConfigurationField>)
Initializes a new instance of the ConfigurationEditor class.
Declaration
protected ConfigurationEditor(List<ConfigurationField> fields)
Parameters
Type | Name | Description |
---|---|---|
List<ConfigurationField> | fields |
Properties
View SourceDefaultConfiguration
Gets the default configuration.
Declaration
[DataMember(Name = "defaultConfig")]
public virtual IDictionary<string, object> DefaultConfiguration { get; set; }
Property Value
Type | Description |
---|---|
IDictionary<System.String, System.Object> |
Fields
Gets the fields.
Declaration
[DataMember(Name = "fields")]
public List<ConfigurationField> Fields { get; }
Property Value
Type | Description |
---|---|
List<ConfigurationField> |
Methods
View SourceConfigurationAs<TConfiguration>(Object)
Gets the configuration as a typed object.
Declaration
public static TConfiguration ConfigurationAs<TConfiguration>(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj |
Returns
Type | Description |
---|---|
TConfiguration |
Type Parameters
Name | Description |
---|---|
TConfiguration |
Field(String)
Gets a field by its property name.
Declaration
protected ConfigurationField Field(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name |
Returns
Type | Description |
---|---|
ConfigurationField |
Remarks
Can be used in constructors to add infos to a field that has been defined by a property marked with the ConfigurationFieldAttribute.
FromConfigurationEditor(IDictionary<String, Object>)
Converts values from the configuration editor to configuration data.
Declaration
public virtual IDictionary<string, object> FromConfigurationEditor(IDictionary<string, object> configuration)
Parameters
Type | Name | Description |
---|---|---|
IDictionary<System.String, System.Object> | configuration | Values from the configuration editor. |
Returns
Type | Description |
---|---|
IDictionary<System.String, System.Object> |
Remarks
Consider this the reverse of ToConfigurationEditor(IDictionary<String, Object>).
FromConfigurationObject(Object, IConfigurationEditorJsonSerializer)
Creates configuration data from a configuration object.
Declaration
public virtual IDictionary<string, object> FromConfigurationObject(object configuration, IConfigurationEditorJsonSerializer configurationEditorJsonSerializer)
Parameters
Type | Name | Description |
---|---|---|
System.Object | configuration | The configuration object. |
IConfigurationEditorJsonSerializer | configurationEditorJsonSerializer | The configuration serializer. |
Returns
Type | Description |
---|---|
IDictionary<System.String, System.Object> |
FromDatabase(String, IConfigurationEditorJsonSerializer)
Converts a serialized database value into configuration data.
Declaration
public virtual IDictionary<string, object> FromDatabase(string configuration, IConfigurationEditorJsonSerializer configurationEditorJsonSerializer)
Parameters
Type | Name | Description |
---|---|---|
System.String | configuration | The serialized database value (JSON format). |
IConfigurationEditorJsonSerializer | configurationEditorJsonSerializer | The configuration serializer. |
Returns
Type | Description |
---|---|
IDictionary<System.String, System.Object> |
ToConfigurationEditor(IDictionary<String, Object>)
Converts the configuration data to values for the configuration editor.
Declaration
public virtual IDictionary<string, object> ToConfigurationEditor(IDictionary<string, object> configuration)
Parameters
Type | Name | Description |
---|---|---|
IDictionary<System.String, System.Object> | configuration | The configuration data. |
Returns
Type | Description |
---|---|
IDictionary<System.String, System.Object> |
ToConfigurationObject(IDictionary<String, Object>, IConfigurationEditorJsonSerializer)
Creates a configuration object from the configuration data.
Declaration
public virtual object ToConfigurationObject(IDictionary<string, object> configuration, IConfigurationEditorJsonSerializer configurationEditorJsonSerializer)
Parameters
Type | Name | Description |
---|---|---|
IDictionary<System.String, System.Object> | configuration | The configuration data. |
IConfigurationEditorJsonSerializer | configurationEditorJsonSerializer | The configuration serializer. |
Returns
Type | Description |
---|---|
System.Object |
ToDatabase(IDictionary<String, Object>, IConfigurationEditorJsonSerializer)
Converts configuration data into a serialized database value.
Declaration
public virtual string ToDatabase(IDictionary<string, object> configuration, IConfigurationEditorJsonSerializer configurationEditorJsonSerializer)
Parameters
Type | Name | Description |
---|---|---|
IDictionary<System.String, System.Object> | configuration | |
IConfigurationEditorJsonSerializer | configurationEditorJsonSerializer |
Returns
Type | Description |
---|---|
System.String |
ToValueEditor(IDictionary<String, Object>)
Converts the configuration data to values for the value editor.
Declaration
public virtual IDictionary<string, object> ToValueEditor(IDictionary<string, object> configuration)
Parameters
Type | Name | Description |
---|---|---|
IDictionary<System.String, System.Object> | configuration | The configuration data. |
Returns
Type | Description |
---|---|
IDictionary<System.String, System.Object> |
Validate(IDictionary<String, Object>)
Performs validation of configuration data.
Declaration
public virtual IEnumerable<ValidationResult> Validate(IDictionary<string, object> configuration)
Parameters
Type | Name | Description |
---|---|---|
IDictionary<System.String, System.Object> | configuration | The configuration data to validate. |
Returns
Type | Description |
---|---|
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> | One or more System.ComponentModel.DataAnnotations.ValidationResult if the configuration data is invalid, an empty collection otherwise. |