Flexberry ORM 8.0.0-beta01
Класс ICSSoft.Services.UnityFactory

Helper class for creating and using Unity containers. Подробнее...

Открытые статические члены

static IUnityContainer CreateContainer ()
 Creates new instance of Unity container and configures it using configuration file (from 'unity' section). Подробнее...
 
static IUnityContainer GetContainer ()
 Gets the singleton instance of Unity container. Подробнее...
 

Подробное описание

Helper class for creating and using Unity containers.

You should avoid using this class when you can. Based on IoC / DI philosophy, you should create and configure you DI container at "composition root" of your application. Using singleton-based static approach is the best possible compromise for situations when you haven't got easy access to it (e.g. ASP.NET WebForms).

Методы

◆ CreateContainer()

static IUnityContainer ICSSoft.Services.UnityFactory.CreateContainer ( )
inlinestatic

Creates new instance of Unity container and configures it using configuration file (from 'unity' section).

Using this method multiple times you'll get different instances of the container each time:

static IUnityContainer CreateContainer()
Creates new instance of Unity container and configures it using configuration file (from 'unity' sect...
Definition: UnityFactory.cs:49

This behavior could be wrong when you want to use singleton (ContainerControlledLifetimeManager) because all lifetime managers work at separate containers (see documentation) and created dependency will live as long as your container.

For getting the same container use GetContainer.

Возвращает
New instance of Unity container.

◆ GetContainer()

static IUnityContainer ICSSoft.Services.UnityFactory.GetContainer ( )
inlinestatic

Gets the singleton instance of Unity container.

The first instance will be created using CreateContainer.

Возвращает
The singleton instance of Unity container.