Изменения документа InversifyJS

Редактировал(а) Alexandr Fokin 2021/07/25 01:02

<
От версии < 2.2 >
отредактировано Alexandr Fokin
на 2021/07/25 00:59
К версии < 2.1 >
отредактировано Alexandr Fokin
на 2021/07/25 00:58
>
Изменить комментарий: К данной версии нет комментариев

Комментарий

Подробности

XWiki.XWikiComments[0]
Автор
... ... @@ -1,1 +1,0 @@
1 -XWiki.cccc1808
Комментарий
... ... @@ -1,43 +1,0 @@
1 -{{code language="JavaScript"}}
2 -import { Container } from "inversify";
3 -
4 -import { Type } from "./Type"
5 -
6 -import { IDal, IDalType } from "../model/dal/IDal"
7 -import { DAL } from "../model/dal/DAL"
8 -
9 -import { CounterCreateParams, CounterProps } from "../components/Counter"
10 -
11 -export class ServiceLocator {
12 -
13 - private static Container: Container;
14 -
15 -
16 - public static Init(container: Container | null = null) {
17 - if (container === null) {
18 - container = new Container();
19 - }
20 -
21 - this.Registry(container);
22 -
23 - this.Container = container;
24 - }
25 -
26 - public static Get<T>(type: Type): T {
27 - var instance = this.Container.get<T>(type.Name);
28 -
29 - if (instance === null) {
30 - throw "Error Get " + type.Name;
31 - }
32 - return instance;
33 - }
34 -
35 - private static Registry(container: Container) {
36 -
37 - container.bind<IDal>(IDalType.Type.Name).to(DAL);
38 -
39 - container.bind<CounterCreateParams>(CounterCreateParams.Type.Name).to(CounterCreateParams);
40 -
41 - }
42 -}
43 -{{/code}}
Дата
... ... @@ -1,1 +1,0 @@
1 -2021-07-25 00:59:38.33