fix build errors

This commit is contained in:
Nikolaj Geisle
2022-04-04 10:34:13 +02:00
parent 57190fc676
commit 4710951185
48 changed files with 117 additions and 87 deletions

View File

@@ -105,11 +105,11 @@ namespace Umbraco.Cms.Core.PropertyEditors
// send: { "items": { "<id>": { "value": "<color>", "label": "<label>", "sortOrder": <sortOrder> } , ... }, "useLabel": <bool> }
// recv: { "items": ..., "useLabel": <bool> }
public override ColorPickerConfiguration FromConfigurationEditor(IDictionary<string, object> editorValues, ColorPickerConfiguration? configuration)
public override ColorPickerConfiguration FromConfigurationEditor(IDictionary<string, object?>? editorValues, ColorPickerConfiguration? configuration)
{
var output = new ColorPickerConfiguration();
if (!editorValues.TryGetValue("items", out var jjj) || !(jjj is JArray jItems))
if (editorValues is null || !editorValues.TryGetValue("items", out var jjj) || !(jjj is JArray jItems))
return output; // oops
// handle useLabel

View File

@@ -125,7 +125,7 @@ namespace Umbraco.Cms.Core.PropertyEditors
}
/// <inheritdoc />
public sealed override object? FromConfigurationEditor(IDictionary<string, object> editorValues, object configuration)
public sealed override object? FromConfigurationEditor(IDictionary<string, object?>? editorValues, object? configuration)
{
return FromConfigurationEditor(editorValues, (TConfiguration?) configuration);
}
@@ -135,7 +135,7 @@ namespace Umbraco.Cms.Core.PropertyEditors
/// </summary>
/// <param name="editorValues">The configuration object posted by the editor.</param>
/// <param name="configuration">The current configuration object.</param>
public virtual TConfiguration? FromConfigurationEditor(IDictionary<string, object> editorValues, TConfiguration? configuration)
public virtual TConfiguration? FromConfigurationEditor(IDictionary<string, object?>? editorValues, TConfiguration? configuration)
{
// note - editorValue contains a mix of CLR types (string, int...) and JToken
// turning everything back into a JToken... might not be fastest but is simplest
@@ -148,7 +148,7 @@ namespace Umbraco.Cms.Core.PropertyEditors
// field only, JsonPropertyAttribute is ignored here
// only keep fields that have a non-null/empty value
// rest will fall back to default during ToObject()
if (editorValues.TryGetValue(field.Key!, out var value) && value != null && (!(value is string stringValue) || !string.IsNullOrWhiteSpace(stringValue)))
if (editorValues is not null && editorValues.TryGetValue(field.Key!, out var value) && value != null && (!(value is string stringValue) || !string.IsNullOrWhiteSpace(stringValue)))
{
if (value is JToken jtoken)
{

View File

@@ -21,11 +21,11 @@ namespace Umbraco.Cms.Core.PropertyEditors
items.Validators.Add(new ValueListUniqueValueValidator());
}
public override DropDownFlexibleConfiguration FromConfigurationEditor(IDictionary<string, object> editorValues, DropDownFlexibleConfiguration? configuration)
public override DropDownFlexibleConfiguration FromConfigurationEditor(IDictionary<string, object?>? editorValues, DropDownFlexibleConfiguration? configuration)
{
var output = new DropDownFlexibleConfiguration();
if (!editorValues.TryGetValue("items", out var jjj) || !(jjj is JArray jItems))
if (editorValues is null || !editorValues.TryGetValue("items", out var jjj) || !(jjj is JArray jItems))
return output; // oops
// handle multiple

View File

@@ -23,19 +23,19 @@ namespace Umbraco.Cms.Core.PropertyEditors
}
/// <inheritdoc />
public override EyeDropperColorPickerConfiguration FromConfigurationEditor(IDictionary<string, object> editorValues, EyeDropperColorPickerConfiguration? configuration)
public override EyeDropperColorPickerConfiguration FromConfigurationEditor(IDictionary<string, object?>? editorValues, EyeDropperColorPickerConfiguration? configuration)
{
var showAlpha = true;
var showPalette = true;
if (editorValues.TryGetValue("showAlpha", out var alpha))
if (editorValues is not null && editorValues.TryGetValue("showAlpha", out var alpha))
{
var attempt = alpha.TryConvertTo<bool>();
if (attempt.Success)
showAlpha = attempt.Result;
}
if (editorValues.TryGetValue("showPalette", out var palette))
if (editorValues is not null && editorValues.TryGetValue("showPalette", out var palette))
{
var attempt = palette.TryConvertTo<bool>();
if (attempt.Success)

View File

@@ -16,14 +16,14 @@ namespace Umbraco.Cms.Core.PropertyEditors
}
/// <inheritdoc />
public override LabelConfiguration FromConfigurationEditor(IDictionary<string, object> editorValues, LabelConfiguration? configuration)
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.TryGetValue(Cms.Core.Constants.PropertyEditors.ConfigurationKeys.DataValueType, out var valueTypeObj)
if (editorValues is not null && editorValues.TryGetValue(Cms.Core.Constants.PropertyEditors.ConfigurationKeys.DataValueType, out var valueTypeObj)
&& valueTypeObj is string stringValue)
{
if (!string.IsNullOrWhiteSpace(stringValue) && ValueTypes.IsValue(stringValue)) // validate

View File

@@ -35,13 +35,13 @@ namespace Umbraco.Cms.Core.PropertyEditors
}
/// <inheritdoc />
public override MultipleTextStringConfiguration FromConfigurationEditor(IDictionary<string, object> editorValues, MultipleTextStringConfiguration? configuration)
public override MultipleTextStringConfiguration FromConfigurationEditor(IDictionary<string, object?>? editorValues, MultipleTextStringConfiguration? configuration)
{
// TODO: this isn't pretty
//the values from the editor will be min/max fields and we need to format to json in one field
// is the editor sending strings or ints or?!
var min = (editorValues.ContainsKey("min") ? editorValues["min"].ToString() : "0").TryConvertTo<int>();
var max = (editorValues.ContainsKey("max") ? editorValues["max"].ToString() : "0").TryConvertTo<int>();
var min = (editorValues?.ContainsKey("min") ?? false ? editorValues["min"]?.ToString() : "0").TryConvertTo<int>();
var max = (editorValues?.ContainsKey("max") ?? false ? editorValues["max"]?.ToString() : "0").TryConvertTo<int>();
return new MultipleTextStringConfiguration
{

View File

@@ -33,14 +33,18 @@ namespace Umbraco.Cms.Core.PropertyEditors
return dictionary;
}
public override TagConfiguration? FromConfigurationEditor(IDictionary<string, object> editorValues, TagConfiguration? configuration)
public override TagConfiguration? FromConfigurationEditor(IDictionary<string, object?>? editorValues, TagConfiguration? configuration)
{
// the front-end editor returns the string value of the storage type
// pure Json could do with
// [JsonConverter(typeof(StringEnumConverter))]
// but here we're only deserializing to object and it's too late
editorValues["storageType"] = Enum.Parse(typeof(TagsStorageType), (string) editorValues["storageType"]);
if (editorValues is not null)
{
editorValues["storageType"] = Enum.Parse(typeof(TagsStorageType), (string) editorValues["storageType"]!);
}
return base.FromConfigurationEditor(editorValues, configuration);
}
}

View File

@@ -67,11 +67,11 @@ namespace Umbraco.Cms.Core.PropertyEditors
}
/// <inheritdoc />
public override ValueListConfiguration FromConfigurationEditor(IDictionary<string, object> editorValues, ValueListConfiguration? configuration)
public override ValueListConfiguration FromConfigurationEditor(IDictionary<string, object?>? editorValues, ValueListConfiguration? configuration)
{
var output = new ValueListConfiguration();
if (!editorValues.TryGetValue("items", out var jjj) || !(jjj is JArray jItems))
if (editorValues is null || !editorValues.TryGetValue("items", out var jjj) || !(jjj is JArray jItems))
return output; // oops
// auto-assigning our ids, get next id from existing values