The answer is probably simple, but I can't find a way to correctly update some code from Umbraco 13 into the 15 equivalent. I have the following code in Umbraco 13 (redacted for easier reading):
csharp
var configuration = new SliderConfiguration
{
EnableRange = false,
MinimumValue = new decimal(0),
MaximumValue = new decimal(1),
}
var editorAlias = Umbraco.Cms.Core.Constants.PropertyEditors.Aliases.Slider;
//How to get the editor from the alias is not important
//serializer is an injected IConfigurationEditorJsonSerializer
var newType = new DataType(editor, serializer)
{
DatabaseType = _databaseType ?? ValueStorageType.Ntext,
CreateDate = DateTime.Now,
CreatorId = -1,
Name = _dataTypeName,
Configuration = configuration
};
In this case, Configuration is an object?. And Umbraco has models (like the SliderConfiguration) for the configuration of the editor associated with the datatype. However, things change a little (but enough) in Umbraco 15:
Configuration is now
ConfigurationData and no longer a object?, but a Dictionary
.
Problem 1: I assume that the dictionary is a collection where the string is a property name and the object it's value. However, I'm not sure because I can't find any documentation on it. Is that's the case, what do I need to use as the keys? I mean, the SliderConfiguration class has some annotations, do I need to use these as key?
csharp
public class SliderConfiguration
{
[ConfigurationField("enableRange")]
public bool EnableRange { get; set; }
[ConfigurationField("minVal")]
public decimal MinimumValue { get; set; }
[ConfigurationField("maxVal")]
public decimal MaximumValue { get; set; }
}
Problem 2 is that I have a perfectly good strong typed model. I don't want to create a dictionary myself and trying to figure out what keys to use. I think there should be some converter/parser that could create the dictionary of my model. Any thoughts?