-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathMsSqlSessionFactoryProviderGetter.cs
42 lines (38 loc) · 1.83 KB
/
MsSqlSessionFactoryProviderGetter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using NHibernate;
using ViennaNET.Orm.Configuration;
using ViennaNET.Orm.Factories;
using ViennaNET.Utils;
using ILoggerFactory = Microsoft.Extensions.Logging.ILoggerFactory;
namespace ViennaNET.Orm.MSSQL
{
/// <inheritdoc />
public class MsSqlSessionFactoryProviderGetter : ISessionFactoryProviderGetter
{
private readonly IConfiguration _configuration;
private readonly IInterceptor _interceptor;
private readonly ILoggerFactory _loggerFactory;
/// <summary>
/// Инициализирует провайдер ссылками на <see cref="IConfiguration" /> и <see cref="IInterceptor" />
/// </summary>
/// <param name="configuration">Ссылка на интерфейс, предоставляющий доступ к конфигурации</param>
/// <param name="interceptor">Ссылка на интерфейс перехватчика для сущностей NHibernate</param>
/// <param name="loggerFactory">Ссылка на стандартный интерфейс фабрики логгеров</param>
public MsSqlSessionFactoryProviderGetter(IConfiguration configuration, IInterceptor interceptor,
ILoggerFactory loggerFactory)
{
_configuration = configuration.ThrowIfNull(nameof(configuration));
_interceptor = interceptor.ThrowIfNull(nameof(interceptor));
_loggerFactory = loggerFactory.ThrowIfNull(nameof(loggerFactory));
}
/// <inheritdoc />
public string Type => "MSSQL";
/// <inheritdoc />
public ISessionFactoryProvider GetSessionFactoryProvider(ConnectionInfo info)
{
return new MsSqlSessionFactoryProvider(info.Nick, _configuration, _interceptor, _loggerFactory,
_loggerFactory.CreateLogger<MsSqlSessionFactoryProvider>());
}
}
}