// ========================================================================== // Squidex Headless CMS // ========================================================================== // Copyright (c) Squidex UG (haftungsbeschraenkt) // All rights reserved. Licensed under the MIT license. // ========================================================================== using System.Collections.Generic; using System.Reflection; using System.Text; using Microsoft.Extensions.Configuration; using Squidex.Infrastructure; namespace Squidex.Web { public sealed class ExposedValues : Dictionary { public ExposedValues() { } public ExposedValues(ExposedConfiguration configured, IConfiguration configuration, Assembly? assembly = null) { Guard.NotNull(configured); Guard.NotNull(configuration); foreach (var kvp in configured) { var value = configuration.GetValue(kvp.Value); if (!string.IsNullOrWhiteSpace(value)) { this[kvp.Key] = value; } } if (assembly != null) { if (!ContainsKey("version")) { this["version"] = assembly.GetName()!.Version!.ToString(); } } } public override string ToString() { var sb = new StringBuilder(); foreach (var kvp in this) { if (sb.Length > 0) { sb.Append(", "); } sb.Append(kvp.Key); sb.Append(": "); sb.Append(kvp.Value); } return sb.ToString(); } } }