26 lines
928 B
C#
26 lines
928 B
C#
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.");
|
|
}
|
|
}
|
|
}
|