forked from amkovkov/GranuSightSoftware2
feat: Camera settings + some refactor
This commit is contained in:
@@ -1,12 +1,35 @@
|
||||
using System.Collections;
|
||||
using System.Text.Json;
|
||||
|
||||
using GSS2.Core.Extentions;
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace GSS2.Core.Abstractions;
|
||||
|
||||
public abstract record ServiceConfigurationBase
|
||||
{
|
||||
public virtual string ToString(string separator, int indent)
|
||||
{
|
||||
List<string?> strs = new List<string?>();
|
||||
var strs = new List<string?>();
|
||||
foreach (var prop in GetType().GetProperties())
|
||||
strs.Add($"{prop.Name}: {prop.GetValue(this)}");
|
||||
{
|
||||
if (prop.GetMethod?.IsStatic != false)
|
||||
continue;
|
||||
|
||||
var value = prop.GetValue(this);
|
||||
|
||||
string? strValue = value switch
|
||||
{
|
||||
string str => str,
|
||||
IConfigurationSection configurationSection => $"\n{(configurationSection.AsDictionary() as IDictionary).ToString(separator, indent * 2)}",
|
||||
IDictionary dictionary => $"\n{dictionary.ToString(separator, indent * 2)}",
|
||||
IEnumerable enumerable => $"\n{enumerable.ToString(separator, indent * 2)}",
|
||||
object obj => obj?.ToString(),
|
||||
_ => null
|
||||
};
|
||||
strs.Add($"{prop.Name}: {strValue}");
|
||||
}
|
||||
return string.Join(separator, strs.Select(s => $"{new string(' ', indent)}{s}"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user