Made methods static

This commit is contained in:
Thorsten Sommer 2025-11-13 16:41:09 +01:00
parent 42d67d512e
commit 871eeecc1d
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108

View File

@ -534,7 +534,7 @@ public abstract class BaseProvider : IProvider, ISecretId
{ {
var json = $"{{{additionalUserProvidedParameters}}}"; var json = $"{{{additionalUserProvidedParameters}}}";
var jsonDoc = JsonSerializer.Deserialize<JsonElement>(json, JSON_SERIALIZER_OPTIONS); var jsonDoc = JsonSerializer.Deserialize<JsonElement>(json, JSON_SERIALIZER_OPTIONS);
var dict = this.ConvertToDictionary(jsonDoc); var dict = ConvertToDictionary(jsonDoc);
// Some keys are always removed because we set them: // Some keys are always removed because we set them:
keysToRemove.Add("stream"); keysToRemove.Add("stream");
@ -554,16 +554,16 @@ public abstract class BaseProvider : IProvider, ISecretId
} }
} }
private IDictionary<string, object> ConvertToDictionary(JsonElement element) private static IDictionary<string, object> ConvertToDictionary(JsonElement element)
{ {
return element.EnumerateObject() return element.EnumerateObject()
.ToDictionary<JsonProperty, string, object>( .ToDictionary<JsonProperty, string, object>(
p => p.Name, p => p.Name,
p => this.ConvertJsonValue(p.Value) ?? throw new InvalidOperationException() p => ConvertJsonValue(p.Value) ?? string.Empty
); );
} }
private object? ConvertJsonValue(JsonElement element) => element.ValueKind switch private static object? ConvertJsonValue(JsonElement element) => element.ValueKind switch
{ {
JsonValueKind.String => element.GetString(), JsonValueKind.String => element.GetString(),
JsonValueKind.Number => element.TryGetInt32(out int i) ? i : JsonValueKind.Number => element.TryGetInt32(out int i) ? i :