2023-09-15 12:37:02 +03:30
|
|
|
|
namespace Brizco.Repository.Extensions;
|
|
|
|
|
|
|
2024-08-09 21:42:04 +03:30
|
|
|
|
public class DbContextOptionCustomExtensionsInfo(IDbContextOptionsExtension extension)
|
|
|
|
|
|
: DbContextOptionsExtensionInfo(extension)
|
2023-09-15 12:37:02 +03:30
|
|
|
|
{
|
|
|
|
|
|
public override bool IsDatabaseProvider { get; }
|
|
|
|
|
|
public override string LogFragment { get; } = string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
public override int GetServiceProviderHashCode()
|
|
|
|
|
|
{
|
|
|
|
|
|
return Extension.GetHashCode();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void PopulateDebugInfo(IDictionary<string, string> debugInfo)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override bool ShouldUseSameServiceProvider(DbContextOptionsExtensionInfo other)
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class DbContextOptionCustomExtensions : IDbContextOptionsExtension
|
|
|
|
|
|
{
|
|
|
|
|
|
public DbContextOptionCustomExtensions()
|
|
|
|
|
|
{
|
|
|
|
|
|
Info = new DbContextOptionCustomExtensionsInfo(this);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Assembly ProjectAssembly { get; set; } = Assembly.GetExecutingAssembly();
|
|
|
|
|
|
|
|
|
|
|
|
public void ApplyServices(IServiceCollection services)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Validate(IDbContextOptions options)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public DbContextOptionsExtensionInfo Info { get; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static class ApplicationContextExtensions
|
|
|
|
|
|
{
|
|
|
|
|
|
public static DbContextOptionsBuilder UseProjectAssembly(this DbContextOptionsBuilder contextOptions,
|
|
|
|
|
|
Assembly projectAssembly)
|
|
|
|
|
|
{
|
|
|
|
|
|
var extension = new DbContextOptionCustomExtensions
|
|
|
|
|
|
{
|
|
|
|
|
|
ProjectAssembly = projectAssembly
|
|
|
|
|
|
};
|
|
|
|
|
|
((IDbContextOptionsBuilderInfrastructure)contextOptions).AddOrUpdateExtension(extension);
|
|
|
|
|
|
return contextOptions;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|