Files
messengerapi/code/MessengerApi.Configuration/Sources/Environment/EnvironmentConfigurationSource.cs
masiton 85c462a614
All checks were successful
Build and Push Docker Image / build (push) Successful in 50s
Build and Push Docker Image / docker (push) Successful in 35s
Updated generic resolution of Guid from config.
2025-07-05 09:05:02 +02:00

21 lines
701 B
C#

namespace MessengerApi.Configuration.Sources.Environment
{
public class EnvironmentConfigurationSource : IEnvironmentConfigurationSource
{
public bool HasKey(string key)
{
return !string.IsNullOrWhiteSpace(System.Environment.GetEnvironmentVariable(key));
}
public T GetValue<T>(string key)
{
if (typeof(T).Equals(typeof(Guid)))
{
var guid = Guid.Parse(System.Environment.GetEnvironmentVariable(key));
return (T)Convert.ChangeType(guid, typeof(T));
}
return (T)Convert.ChangeType(System.Environment.GetEnvironmentVariable(key), typeof(T));
}
}
}