Add Application configuration #11

Merged
Wesser merged 128 commits from feat/add-setup into release/v1.0.0 2024-06-01 07:35:30 +03:00
Showing only changes of commit 348b78b84e - Show all commits

View File

@ -0,0 +1,23 @@
using Mirea.Api.DataAccess.Persistence.EntityTypeConfigurations;
using System;
using System.Linq;
using System.Reflection;
namespace Mirea.Api.DataAccess.Persistence.Common;
public static class ConfigurationResolver
{
public static Type GetConfigurationType<TEntity>(DatabaseProvider provider)
where TEntity : class
{
var entityType = typeof(TEntity);
var providerNamespace = typeof(Mark).Namespace + "." + Enum.GetName(provider);
var assembly = Assembly.GetExecutingAssembly();
var configurationType = assembly.GetTypes()
.FirstOrDefault(t => t.Namespace != null && t.Namespace.StartsWith(providerNamespace) && t.Name == $"{entityType.Name}Configuration");
return configurationType ??
throw new InvalidOperationException($"Configuration type not found for entity {entityType.Name} and provider {provider}.");
}
}