Headless CMS and Content Managment Hub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

65 lines
1.8 KiB

// ==========================================================================
// 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<string, string>
{
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<string>(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();
}
}
}