Initial commit carried over from private repo. This is V2.
This commit is contained in:
11
code/MessengerApi.Configuration/Parsers/CorsParser.cs
Normal file
11
code/MessengerApi.Configuration/Parsers/CorsParser.cs
Normal file
@ -0,0 +1,11 @@
|
||||
namespace MessengerApi.Configuration.Parsers
|
||||
{
|
||||
public static class CorsParser
|
||||
{
|
||||
public static string[] Parse(string value)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value)) return [];
|
||||
return value.Trim().Split(",", StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
using MessengerApi.Configuration.Model.Persistence;
|
||||
using MessengerApi.Configuration.Model.Persistence.Base;
|
||||
using MessengerApi.Configuration.Sources.Environment;
|
||||
|
||||
namespace MessengerApi.Configuration.Parsers
|
||||
{
|
||||
public static class EnvironmentPersistenceConfigurationParser
|
||||
{
|
||||
public static PersistenceConfiguration Parse(IEnvironmentConfigurationSource config)
|
||||
{
|
||||
var type = PersistenceTypeParser.Parse(config.GetValue<string>(Constants.EnvironmentVariables.PERSISTENCE_TYPE));
|
||||
|
||||
if(type == Enums.PersistenceTypes.Sql)
|
||||
{
|
||||
return new SqlPersistenceConfiguration(config);
|
||||
}
|
||||
else if(type == Enums.PersistenceTypes.PostgreSql)
|
||||
{
|
||||
return new NpgPersistenceConfiguration(config);
|
||||
}
|
||||
|
||||
throw new InvalidOperationException("Unrecognized persistence type.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
using MessengerApi.Configuration.Enums;
|
||||
|
||||
namespace MessengerApi.Configuration.Parsers
|
||||
{
|
||||
public static class HousekeepingMessageStateParser
|
||||
{
|
||||
public static HousekeepingMessageStates Parse(string input)
|
||||
{
|
||||
return (HousekeepingMessageStates)Enum.Parse(typeof(HousekeepingMessageStates), input.Trim(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
using MessengerApi.Configuration.Enums;
|
||||
|
||||
namespace MessengerApi.Configuration.Parsers
|
||||
{
|
||||
public static class LoggingVerbosityParser
|
||||
{
|
||||
public static LoggingVerbosity Parse(string value)
|
||||
{
|
||||
return (LoggingVerbosity)Enum.Parse(typeof(LoggingVerbosity), value.Trim(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
using MessengerApi.Configuration.Enums;
|
||||
|
||||
namespace MessengerApi.Configuration.Parsers
|
||||
{
|
||||
public static class PersistenceTypeParser
|
||||
{
|
||||
public static PersistenceTypes Parse(string value)
|
||||
{
|
||||
return (PersistenceTypes)Enum.Parse(typeof(PersistenceTypes), value, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
code/MessengerApi.Configuration/Parsers/ProxiesParser.cs
Normal file
11
code/MessengerApi.Configuration/Parsers/ProxiesParser.cs
Normal file
@ -0,0 +1,11 @@
|
||||
namespace MessengerApi.Configuration.Parsers
|
||||
{
|
||||
public static class ProxiesParser
|
||||
{
|
||||
public static string[] Parse(string value)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value)) return [];
|
||||
return value.Trim().Split(",", StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user