Development Merge 2026.04.03 #8

Merged
Syntriax merged 51 commits from development into main 2026-04-03 14:08:02 +02:00
2 changed files with 6 additions and 4 deletions
Showing only changes of commit c11aced8d2 - Show all commits

View File

@@ -12,17 +12,18 @@ public class BasicConfiguration : IConfiguration
public IReadOnlyDictionary<string, object?> Values => values; public IReadOnlyDictionary<string, object?> Values => values;
public T? Get<T>(string key, T? defaultValue = default) public T Get<T>(string key, T defaultValue) => Get<T>(key) ?? defaultValue;
public T? Get<T>(string key)
{ {
if (!values.TryGetValue(key, out object? value)) if (!values.TryGetValue(key, out object? value))
return defaultValue; return default;
if (value is T castedObject) if (value is T castedObject)
return castedObject; return castedObject;
try { return (T?)System.Convert.ChangeType(value, typeof(T)); } catch { } try { return (T?)System.Convert.ChangeType(value, typeof(T)); } catch { }
return defaultValue; return default;
} }
public object? Get(string key) public object? Get(string key)

View File

@@ -15,7 +15,8 @@ public interface IConfiguration
bool Has(string key); bool Has(string key);
object? Get(string key); object? Get(string key);
T? Get<T>(string key, T? defaultValue = default); T Get<T>(string key, T defaultValue);
T? Get<T>(string key);
void Set<T>(string key, T value); void Set<T>(string key, T value);
void Remove<T>(string key); void Remove<T>(string key);