forked from amkovkov/GranuSightSoftware2
feat: Camera settings + some refactor
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace GSS2.Core.Extentions;
|
||||
|
||||
public static class ConfiurationSectionExtensions
|
||||
{
|
||||
public static Dictionary<string, string> AsDictionary(this IConfigurationSection values)
|
||||
{
|
||||
var dict = new Dictionary<string, string>();
|
||||
foreach (var (key, value) in values.AsEnumerable())
|
||||
if (value is not null)
|
||||
dict.Add(key.Substring(values.Path.Length + 1), value);
|
||||
return dict;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,30 @@
|
||||
using System.Collections;
|
||||
|
||||
namespace GSS2.Core.Extentions;
|
||||
|
||||
public static class EnumerableExtensions
|
||||
{
|
||||
public static IEnumerable<(int i, T value)> Enumerate<T>(this IEnumerable<T> values) => values.Select((value, i) => (i, value));
|
||||
|
||||
public static string ToString<TKey, TValue>(this IDictionary<TKey, TValue> values, string separator, int indent) => string.Join(separator, values.Select(v => $"{new string(' ', indent)} {v.Key}: {v.Value}"));
|
||||
public static string ToString(this IDictionary values, string separator, int indent)
|
||||
{
|
||||
var strs = new List<string?>();
|
||||
var enumerator = values.GetEnumerator();
|
||||
while (enumerator.MoveNext())
|
||||
strs.Add($"{enumerator.Key}: {enumerator.Value}");
|
||||
return string.Join(separator, strs.Select(s => $"{new string(' ', indent)}{s}"));
|
||||
}
|
||||
|
||||
public static string ToString<TValue>(this IEnumerable<TValue> values, string separator, int indent) => (values as IEnumerable).ToString(separator, indent);
|
||||
public static string ToString(this IEnumerable values, string separator, int indent)
|
||||
{
|
||||
var strs = new List<string?>();
|
||||
var enumerator = values.GetEnumerator();
|
||||
while (enumerator.MoveNext())
|
||||
strs.Add(enumerator.Current.ToString());
|
||||
return string.Join(separator, strs.Select(s => $"{new string(' ', indent)}{s}"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user