-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathOrmPackage.cs
41 lines (36 loc) · 1.66 KB
/
OrmPackage.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
using NHibernate;
using SimpleInjector;
using SimpleInjector.Packaging;
using ViennaNET.Diagnostic;
using ViennaNET.Orm.Application;
using ViennaNET.Orm.DI;
using ViennaNET.Orm.Diagnostic;
using ViennaNET.Orm.Factories;
using ViennaNET.Orm.Repositories;
using ViennaNET.Orm.Seedwork;
namespace ViennaNET.Orm.DefaultConfiguration
{
/// <inheritdoc />
/// <summary>
/// Пакет SimpleInjector для работы с ORM на основе NHibernate
/// </summary>
public class OrmPackage : IPackage
{
/// <inheritdoc />
public void RegisterServices(Container container)
{
var registration = Lifestyle.Singleton.CreateRegistration<EntityFactoryService>(container);
container.AddRegistration<IEntityFactoryService>(registration);
container.AddRegistration<IEntityRepositoryFactory>(registration);
container.Register<ISessionFactoryManager, SessionFactoryManager>(Lifestyle.Singleton);
container.Register<IInterceptor, DomainEventsInterceptor>(Lifestyle.Singleton);
container.Register<ISessionManagerProvider, SessionManagerProvider>(Lifestyle.Singleton);
container.Register<ISessionFactoryProvidersManager, SessionFactoryProvidersManager>(Lifestyle.Singleton);
container.Register<ISessionManager, ScopedSessionManager>(Lifestyle.Scoped);
container.Register<IApplicationContextProvider, ApplicationContextProvider>(Lifestyle.Singleton);
container.Collection.Register<IBoundedContext>(GetType().Assembly);
container.Collection.Register<ISessionFactoryProviderGetter>(GetType().Assembly);
container.Collection.Append<IDiagnosticImplementor, OrmConnectionsChecker>(Lifestyle.Singleton);
}
}
}