public static DataValueEditor CreateDataValueEditor(string name) { var valueType = ValueTypes.IsValue(name) ? name : ValueTypes.String; return(new DataValueEditor( Mock.Of <ILocalizedTextService>(), Mock.Of <IShortStringHelper>(), new JsonNetSerializer(), Mock.Of <IIOHelper>(), new DataEditorAttribute(name, name, name) { ValueType = valueType })); }
/// <inheritdoc /> public override LabelConfiguration FromConfigurationEditor( IDictionary <string, object?>?editorValues, LabelConfiguration?configuration) { var newConfiguration = new LabelConfiguration(); // get the value type // not simply deserializing Json because we want to validate the valueType if (editorValues is not null && editorValues.TryGetValue( Constants.PropertyEditors.ConfigurationKeys.DataValueType, out var valueTypeObj) && valueTypeObj is string stringValue) { // validate if (!string.IsNullOrWhiteSpace(stringValue) && ValueTypes.IsValue(stringValue)) { newConfiguration.ValueType = stringValue; } } return(newConfiguration); }